Aaron
Aaron

Reputation: 3325

Need help again altering output of script

wget --output-document=- http://runescape.com/title.ws 2>/dev/null \
| grep PlayerCount \
| head -1l \
| sed 's/^[^>]*>//' \
| sed "s/currently.*$/$(date '+%m\/%d\/%Y %H:%m:%S')/" \
| cut -d">" -f 3,4 \
| sed 's/<\/span>//' \
| awk '{print $3, $4, $1, $2}'

Will output:

03/19/2012 18:03:58 123,822 people

Would anyone be able to help me rewrite this so the output looks like:

03/19/2012 18:03:58,123822,people

I need it this way because when I import it into googledocs, everything with a comma gets separated. Thanks if you help!

Upvotes: 2

Views: 65

Answers (2)

Piotr
Piotr

Reputation: 39

wget --output-document=- http://runescape.com/title.ws 2>/dev/null | perl -le 'use POSIX qw(strftime); while(<>) { if (/PlayerCount.*?(\d*),(\d*).*?currently.*/) { print strftime ("%d/%m/%Y %H:%M:%S", localtime) . ",$1$2,people"} }'

Upvotes: 3

Andy Friese
Andy Friese

Reputation: 6489

wget --output-document=- http://runescape.com/title.ws 2>/dev/null \
| grep PlayerCount \
| head -1l \
| sed 's/^[^>]*>//' \
| sed "s/currently.*$/$(date '+%m\/%d\/%Y %H:%m:%S')/" \
| cut -d">" -f 3,4 \
| sed 's/<\/span>//' \
| sed 's/,//' \
| awk '{printf "%s %s,%s,%s\n", $3, $4, $1, $2}'

Upvotes: 3

Related Questions