This one-liner will print a listing of all ABC News articles from the XML RSS feed. This is a very good way to extract text from an RSS feed or other XML files.
curl -s http://www.abc.net.au/news/feed/2942460/rss.xml | grep 'media:description' | awk -F "[<>]" '{print $3}'; echo "$desc" |
This is an example of the output.
4.4 Mon May 04 jason@Yog-Sothoth 0: $ curl -s http://www.abc.net.au/news/feed/2942460/rss.xml | grep 'media:description' | awk -F "[<>]" '{print $3}'; echo "$desc" Former Carlton assistant coach Dean Laidley appeared in court on Sunday night and did not apply for bail. (AAP: Julian Smith) The New Zealand Warriors landed in Tamworth base, in regional NSW, around 5:30pm. (ABC News) The men are charged over allegedly fixing an online game of Counter-Strike: Global Offensive. (Supplied: Counter-Strike) Scott McLaughlin (R) was struggling in the final lap before a crash allowed him to win the Indy175 virtual race. (AP/iRacing IndyCar) Former Australian Sports Anti-Doping Authority ASADA CEO David Sharpe will head a new sporting integrity agency. (AAP: Mick Tsikas) Sporting organisations have until June 30 to sign up to the national redress scheme. (Unsplash: Alyssa Ledesma) The federal judge threw out the unequal pay claim, but allowed the allegations of discriminatory working conditions to go to trial. (AP: Alessandra Tarantino) AFL chief Gillon McLachlan says there is more optimism and confidence that the league will return to play. (AAP: James Ross, file photo) When sports restrictions ease, initially 10 players will be able to play non-contact Aussie Rules. (Supplied: Ace Coote) The New Zealand Warriors' participation in the NRL season has been in doubt after foreign travellers were banned from entering Australia. (AAP: David Rowland) |
Give this example a go if you are stuck when working with XML and you wish to extract certain entries from the file easily.
To grep more than one item, use grep like this.
4.4 Mon May 04 jason@Yog-Sothoth 0: $ curl -s http://www.abc.net.au/news/feed/2942460/rss.xml | grep -e 'pubDate' -e 'title' | awk -F "[<>]" '{print $3}'; echo "$desc" ABC Grandstand Sport Mon, 04 May 2020 00:19:51 +1000 Former North Melbourne coach Dean Laidley in custody Mon, 04 May 2020 00:19:51 +1000 Unwell Warriors player stays home as team lands in Australia Sun, 03 May 2020 15:17:07 +1000 Five men in their 20s charged with esports match fixing Sun, 03 May 2020 12:24:04 +1000 Scott McLaughlin does 'a Bradbury' to win virtual IndyCar race Sun, 03 May 2020 12:10:25 +1000 Head of new sport integrity agency targets organised crime as greatest threat Sun, 03 May 2020 08:45:37 +1000 Multiple abuse claims from athletes but even wealthy sports yet to sign up to redress scheme Sun, 03 May 2020 07:15:55 +1000 Unequal pay claim for US women's football team thrown out in court Sun, 03 May 2020 06:46:36 +1000 June restart plausible, says AFL boss McLachlan Sat, 02 May 2020 16:08:06 +1000 This is what the return of Australian sport might look like Sat, 02 May 2020 12:02:53 +1000 Warriors get green light to come to Australia for NRL season Sat, 02 May 2020 10:26:07 +1000 Here's how coronavirus restrictions are easing in some states |
So, this would be very useful in a script to extract XML entries. I finally managed to get this working, and I am very happy about that.