Skip to content

Instantly share code, notes, and snippets.

@iwconfig
Last active December 7, 2021 17:31
Show Gist options
  • Save iwconfig/b0c38b5881d60dde38ccf62e0a609001 to your computer and use it in GitHub Desktop.
Save iwconfig/b0c38b5881d60dde38ccf62e0a609001 to your computer and use it in GitHub Desktop.
parse yaml in pure bash
#!/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