Thursday 21 May 2009

twithash

twithash - a shell script to search tweets (uses wget and awk)

#=cut here=======================================================
#!/bin/bash
if [ "$1" == "" ] ; then echo "Usage: twithash searchterm (nb. # added automatically)"
else wget -q -O - http://search.twitter.com/search.atom?q=%23$1|awk '/title/ { gsub("[<</]*title>","") ;text=$0} /<name>/{ gsub ("[<</]*name>",""); split($0,N);print N[1]":"substr(text,4)}'
fi
#================================================================


use with "watch" command to monitor a twitter hashtag in a shell
eg. watch -n 60 twithash qanda

example output:

armagny: #qanda Penny Wong continues to impress with self control and absence of sneer or carp.
armagny: #qanda Unethical spin spend is where you take money given for policy advisers & give to journos, or other flakes
jackwork:khas
BLOWFLYwine: Clean coal is vaporware... but if Penny doesn't sell it, the government would be concerned about losing future tax revenue #qanda
...

No comments: