Last active
December 7, 2021 17:31
-
-
Save iwconfig/b0c38b5881d60dde38ccf62e0a609001 to your computer and use it in GitHub Desktop.
parse yaml in pure bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
ryml () { local IFS=': ' ; read E C ;} | |
while ryml; do # alternatively: while IFS=': ' read E C; do | |
case $E in | |
parent) | |
parent=${E} ;; | |
child) | |
echo ${parent}.${E}: ${C} ;; | |
esac | |
done < "${1-/dev/stdin}" # reverse: < <(tac < "${1-/dev/stdin}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment