玩家外壳脚本:用于抓取数据并减去从游戏A和B
wget --output-document=- http://runescape.com/title.ws 2>/dev/null \
| grep PlayerCount \
| head -1l \
| sed 's/^[^>]*>//' \
| sed "s/currently.*$/$(date '+%r %b %d %Y')/" \
| cut -d">" -f 3,4 \
| sed 's/<\/span>//'
输出:111,048 people 10:43:54 PM Feb 22 2013
玩家从游戏B:
wget --output-document=- http://oldschool.runescape.com/ 2>/dev/null | grep "people playing"
输出:There are currently 42823 people playing!
我想知道有多少玩A游戏,但我不太确定如何玩这个游戏数字你这两个输出的获得,并以同样的格式是这样减去他们,将他们输出:
`111,048 people 10:43:54 PM Feb 22 2013`
一旦你把数字变成变量,用'(($ a - $ b))'来减去它们。 – Barmar 2013-02-23 04:04:56
谢谢。只是不知道如何修剪和存储数字,然后再次显示它:( – Aaron 2013-02-23 04:06:29
你说你被困在数学部分。它看起来像我有一个如何使用sed拉开字符串的句柄。 – Barmar 2013-02-23 04:08:31