reviewed sed to get Link and Title
This commit is contained in:
parent
468f533710
commit
2888cb0faf
|
@ -74,6 +74,7 @@ yes_or_no() {
|
|||
|
||||
cleanup () {
|
||||
rm -f feed.xml
|
||||
rm -f feed_old.xml
|
||||
rm -f status.txt
|
||||
exit $1
|
||||
}
|
||||
|
@ -86,11 +87,16 @@ if ! [[ $? == "0" ]]; then echo "Error."; cleanup 1; else echo "Done."; fi
|
|||
grep -q '<rss' feed.xml
|
||||
if ! [[ $? == "0" ]]; then echo "This is not a RSS feed. Exiting."; cleanup 1; fi
|
||||
|
||||
# Clean up RSS from tabs
|
||||
mv feed.xml feed_old.xml; cat feed_old.xml | tr -d ' ' > feed.xml
|
||||
|
||||
# Find 2nd clean title (1st post) and replaces / with \/
|
||||
TITLE=$(awk '/<title>/{++n; if (n==2) {print; exit}}' feed.xml | sed 's/<title>//g; s/<\/title>//g; s/^ *//g')
|
||||
TITLE=$(awk '/<title>/{++n; if (n==2) {print; exit}}' feed.xml | sed -e 's/<title>\(.*\)<\/title>/\1/' | xargs)
|
||||
#echo "TITLE: $TITLE"
|
||||
|
||||
# Find the link of the article
|
||||
LINK=$(grep -A1 "$TITLE" feed.xml | tail -n 1 | sed 's/<link>//g; s/<\/link>//g; s/ //g')
|
||||
LINK=$(grep -A1 "<title>$TITLE" feed.xml | tail -n 1 | sed 's/<link>\(.*\)<\/link>/\1/' | xargs)
|
||||
#echo "LINK: $LINK"
|
||||
|
||||
# Replace / with \/ in the link
|
||||
LINK_FIXED=$(echo $LINK | sed 's./.\\/.g')
|
||||
|
|
Loading…
Reference in New Issue