2
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!

2
  • 2
    Um, I'm pretty sure you can replace all that with a single awk script... Commented Mar 19, 2012 at 22:51
  • See awk manual for printf Commented Mar 19, 2012 at 22:54

2 Answers 2

3
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}'
Sign up to request clarification or add additional context in comments.

Comments

3
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"} }'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.