Created
March 24, 2014 20:01
-
-
Save Exodus111/9747857 to your computer and use it in GitHub Desktop.
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
#!/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