This simple one-liner will print out all of the news headlines from the BBC news website in a simple text format. This is useful if you want to do something with a list like this. Or if you just want a listing to see if there is anything interesting happening. Updated command for 2017, as it was not working as it used to.
curl -s http://feeds.bbci.co.uk/news/rss.xml | grep "<title>" | sed "s/ <title><\!\[CDATA\[//g;s/\]\]><\/title>//;" | grep -v "BBC News" |
Here is this one-liner in action.
[jason@localhost ~]$ curl -s http://feeds.bbci.co.uk/news/rss.xml | grep "<title>" | sed "s/ <title><\!\[CDATA\[//g;s/\]\]><\/title>//;" | grep -v "BBC News" North Korea: China urges Trump not to worsen situation UKIP MEP quits as whip over anti-Islam candidate Sunderland gas explosion survivor 'saved by fridge' Golders Green murder: Joshua Cohen wanted by police Taylor Swift assault case: Judge throws out DJ's lawsuit US police officer records moment he is shot at close range East Harling murder: Man held over Peter Wrighton stabbing Perseid meteor shower set to peak at weekend Government to consider laser pen licence after attack rise White nationalist rally at University of Virginia Danish submarine owner arrested over journalist's death Drink spiking: Southampton student recounts experience Corsica fires: Blazes continue in Pietracorbara and Sisco Week in pictures: 5 - 11 August 2017 The papers: US 'locked and loaded' and childbirth rethink Hairdressers refuse to shave depressed teen's matted hair Brian Blessed 'bit off' umbilical cord delivering baby Antarctica fruitcake: 106-year-old dessert 'left by Capt Scott' Acid victim: 'I will have my injuries to the grave' Mexico: An open-top bus tour exposes corruption Drinking outside the box: Is bag-in-box wine back? Berlin's new toilets: Would you use a women's urinal? Secret bunker cannabis growers jailed 'I've come to rescue you': My grandfather at Dunkirk 'Airlines keep breaking my wheelchair' Magazines: How print is surviving the digital age The family who brought an Indian sweet to Pakistan The weird and wonderful world of pub games How close is Japanese knotweed getting to my home? For Trump, opulence, golf and nuclear threat Why is the US dollar falling? The Italian highlanders who may have Scottish roots World Championships 2017: Usain Bolt's Jamaica & GB through to relay final Arsenal 4-3 Leicester City Man Utd: Why I back Jose Mourinho's side to win Premier League title - Alan Shearer World Athletics Championships 2017: GB relay teams safely through to 4x100m finals US PGA Championship 2017: Hideki Matsuyama shoots 64 to share lead with Kevin Kisner |
This is a very good way to get a listing of news items in your terminal. Very useful indeed.
Count the number of headlines like this.
[jason@localhost ~]$ curl -s http://feeds.bbci.co.uk/news/rss.xml | grep "<title>" | sed "s/ <title><\!\[CDATA\[//g;s/\]\]><\/title>//;" | grep -v "BBC News" | wc -l 37 |
This example will only print the first 10 headlines. This is a good way to see the most recent news articles.
jason@jason-Lenovo-H50-55:~$ curl -s http://feeds.bbci.co.uk/news/rss.xml | grep "<title>" | sed "s/ <title><\!\[CDATA\[//g;s/\]\]><\/title>//;" | grep -v "BBC News" | head -n 10 China warns US sanctions will void trade talks Sajid Javid pledges 'fresh look' at migration rules 2,000 extra security service officers promised Do you know what you're smoking? Crafty crayfish removes own claw to escape China hotpot British Soap Awards: Connor McIntyre wins 'villain of the year' Disposable coffee cup bans unnecessary, says manufacturer Simon Cowell ditches phone for 10 months - and counting Jordanians in third night of tax rise protests Churchgoers help stop modern slavery at car washes |
GOD BLESS YOU BRO <3
YOU HELPED ME MORE THAN A LOT!!
Very good script, but how do you get rid of the statical data at the top? I want top see just the beginning of the headline and the rest.
Thanks,
Don
I have updated the post with a new command, and I removed the Slashdot example, as it was not working.