2012-03-19 2 views
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}' 

출력 :스크립트의 출력을 변경 다시 도움이 필요

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

같은 사람이 날이 너무 출력이 보이는 다시 도움을 줄 수 있을까 : 나는이 방법이 필요

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

googledocs로 가져올 때마다 쉼표가있는 항목이 모두 분리되기 때문입니다. 도와 주셔서 감사합니다!

+2

음, http://www.gnu.org/software/ (당신이 [printf와]의 AWK 설명서를 참조하십시오 ... 하나의 awk 스크립트와 –

+0

를 모두 교체 할 수 있습니다 확신 해요 gawk/manual/html_node/Printf-Examples.html # Printf-Examples) –

답변

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}' 
+0

대단히 감사합니다. – Aaron

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