Skip to content

Instantly share code, notes, and snippets.

@iwconfig
Last active December 7, 2021 17:32
Show Gist options
  • Save iwconfig/efc6ff1774630a6526988a4ee5555045 to your computer and use it in GitHub Desktop.
Save iwconfig/efc6ff1774630a6526988a4ee5555045 to your computer and use it in GitHub Desktop.
parse xml in pure bash
#!/usr/bin/env bash
rdom () { local IFS=\> ; read -d \< E C ;}
while rdom; do # alternatively: while IFS=\> read -d \< E C; do
case $E in
tvshow|episodedetails)
parent=${E} ;;
title|showtitle|season|episode|plot|aired|thumb)
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