Skip to content

Instantly share code, notes, and snippets.

@Exodus111
Created March 24, 2014 20:01
Show Gist options
  • Save Exodus111/9747857 to your computer and use it in GitHub Desktop.
Save Exodus111/9747857 to your computer and use it in GitHub Desktop.
#!/bin/bash
uri=$1 #URI of RSS Feed
lines=$2 #Number of headlines
titlenum=$3 #Number of extra titles
#Script start
#Require a uri, as a minimum
if [[ "$uri" == "" ]]; then
echo "No URI specified, cannot continue!" >&2
echo "Please read script for more information" >&2
else
#Set defaults if none specified
if [[ $lines == "" ]]; then lines=5 ; fi
if [[ $titlenum == "" ]]; then titlenum=2 ; fi
#The actual work
curl -s --connect-timeout 30 $uri |\
sed -e 's/<\/title>/\n/g' |\
grep -o '<title>.*' |\
sed -e 's/<title>//' |\
head -n $(($lines + $titlenum)) |\
tail -n $(($lines))
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment