-
Notifications
You must be signed in to change notification settings - Fork 5
/
RSS
executable file
·54 lines (43 loc) · 1 KB
/
RSS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# Written By Woland
# Super basic RSS script
# Add RSS link to FEED_URL or specify with -f
#Dependency:
# curl sed awk
# https://github.com/wolandark
# https://github.com/wolandark/BASH_Scripts_For_Everyone
USAGE="Usage: $0 [-h] [-f FEED_URL]"
usage() {
echo $USAGE
echo " -h display this help message"
echo " -f FEED_URL specify the URL of the RSS feed"
}
FEED_URL="http://rss.cnn.com/rss/cnn_topstories.rss"
while getopts ":hf:" opt; do
case ${opt} in
h )
usage
exit 0
;;
f )
FEED_URL=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
: )
echo "Option -$OPTARG requires an argument." >&2
usage
exit 1
;;
esac
done
if [ -z "$FEED_URL" ]; then
echo "Please provide a URL for the RSS feed."
usage
exit 1
fi
curl -s $FEED_URL > feed.xml
sed -e 's/>/>\n/g' feed.xml | awk '/title/ , /\/title/' | grep -v 'title>' | sed -e 's/^.*\[//' -e 's/...$//'