You are not logged in.
I was a looking for a simple bash way to know the age of the latest post on Arch News.
I found that it is very easy to do it, and I post it on the forum because I think it could be useful for script.
(Indeed, I was writing this to do my own "pacup" script: check news, etckeeper, pacman -Su, etckeeper)
$(($((`date '+%s'`-`curl -s http://www.archlinux.org/feeds/news/|xml sel -t -v '//lastBuildDate'|xargs -0 date '+%s' -d`))/60/60/24))
yep, this is a single line
Of course this lacks of readability. The "long" version is this:
latest_post_date=$(curl -s http://www.archlinux.org/feeds/news/|xml sel -t -v '//lastBuildDate')
latest_post_date_sec=$(date '+%s' -d "$latest_post_date")
let diff=`date '+%s'`-$latest_post_date_sec
echo $((diff/60/60/24))
The only dependencies are curl and xmlstarlet, which unfortunately is only in aur.
It shouldn't be difficult to write a version that doesn't need it, I suppose.
EDIT: added curl dependency
Last edited by BoySka (2010-05-24 06:23:12)
Offline
I think you also need curl.
Edit:
curl -s http://www.archlinux.org/news/ | grep 2010 | head -n1 | cut -c 9-18
Last edited by karol (2010-05-23 22:31:48)
Offline
I think you also need curl.
ooops, you're right of course
Edit:
curl -s http://www.archlinux.org/news/ | grep 2010 | head -n1 | cut -c 9-18
Wow, this is good, but it's year-dependant. So here is my proposal again:
curl -s http://www.archlinux.org/news/ | grep '<td>' |head -n1 |cut -c 9-18
Offline
Hope you dont mind I patched it a little.
curl -s http://www.archlinux.org/news/ | grep '<td>'|head -2|perl -pe 'chomp;s;^\s+<td>(.+)</td>;$1: ;'|perl -pe 's/<a href.+">(.+)<.+/$1\n/'
2010-05-17: 2010.05 snapshots. Less is more.
And if you only want the date:
perl -eMLWP::Simple 'for(get('http://www.archlinux.org/news/')){if($_=~/<td>(.+)<\/td>/){$f=$1;}print"$f\n";}'
Last edited by dmz (2010-05-24 07:13:16)
Offline
If I get it right, you want to check whether there are any related notices every time the users performs an update? Is date-based really universal?
I would suggest grepping the news for the names of the packages that are getting updated.
Offline
Why not use rsstail instead?
Offline
Hope you dont mind I patched it a little.
I posted it here for this reason
curl -s http://www.archlinux.org/news/ | grep '<td>'|head -2|perl -pe 'chomp;s;^\s+<td>(.+)</td>;$1: ;'|perl -pe 's/<a href.+">(.+)<.+/$1\n/'
This output is very cool, and it doesn't even depends on xmlstarlet. Definitely +1
And if you only want the date:
perl -eMLWP::Simple 'for(get('http://www.archlinux.org/news/')){if($_=~/<td>(.+)<\/td>/){$f=$1;}print"$f\n";}'
this, instead, does nothing on my box
Offline
If I get it right, you want to check whether there are any related notices every time the users performs an update? Is date-based really universal?
No, it's not universal. But on my box it is pretty useful, since I do updates fairly often. So, only recent news are relevants.
Of course, keeping an md5sum somewhere would be more correct.
I would suggest grepping the news for the names of the packages that are getting updated.
Even this method is good, and I'm going to implement it
Offline