Skip to content

Instantly share code, notes, and snippets.

@megasaturnv
Last active October 16, 2023 07:29
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save megasaturnv/fba1b2f81cdb1d6ac63b73cf0eb839a6 to your computer and use it in GitHub Desktop.
Save megasaturnv/fba1b2f81cdb1d6ac63b73cf0eb839a6 to your computer and use it in GitHub Desktop.
Shell script / one-liner to parse and display an rss feed. May require tweaking for RSS feeds without newlines or where <title> and <description> are on separate lines to their text.
#!/bin/sh
#Megasaturnv 2017-07-28
#Url of the RSS feed
RSS_URL=""
##Commented version:
#Download the rss feed
curl --silent "$RSS_URL" | \
#Only match lines with 'title>' or 'description>'
grep -E '(title>|description>)' | \
#Remove the first 3 lines
tail -n +4 | \
#Other methods which use sed instead of tail
#sed -n '4,$p' | \
#sed -e '1,3d' | \
#Remove all leading whitespace from each line (spaces and tabs)
sed -e 's/^[ \t]*//' | \
#Remove all title and description tags. '<description>' is replaced with ' ' to indent it
sed -e 's/<title>//' -e 's/<\/title>//' -e 's/<description>/ /' -e 's/<\/description>//'
###############################
##Command all on one line:
curl --silent "$RSS_URL" | grep -E '(title>|description>)' | tail -n +4 | sed -e 's/^[ \t]*//' | sed -e 's/<title>//' -e 's/<\/title>//' -e 's/<description>/ /' -e 's/<\/description>//'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment