#!/bin/sh
url="http://slashdot.org/index.rss"
if [ $# -eq 1 ] ; then
headarg=$(( $1 * 2 ))
else
headarg="-8" # default is four headlines
fi
curl --silent "$url" | grep -E '(title>|description>)' | \
sed -n '4,$p' | \
sed -e 's/<title>//' -e 's/<\/title>//' -e 's/<description>/ /' \
-e 's/<\/description>//' | \
head $headarg | fmt
exit 0
Save this as slash-rss.sh and then you can run it as sh slash-rss.sh or,
if you'd prefer, use chmod +x slash-rss.sh then run it as ./slash-rss.sh.
Code inspired by the many scripts included in my popular book Wicked Cool Shell Scripts.