linux - 改变脚本的输出

标签 linux shell timestamp

这段代码:

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>//'

输出类似于:

112,915 people 10:44:54 PM Mar 18 2012

任何人都可以帮我把它打印成这样吗:

3/18/2012 22:44:54 112,915 people

谢谢!

最佳答案

你必须这样命令:

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

关于linux - 改变脚本的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9764383/

相关文章:

linux - Linux中如何将一个位置的文件和子文件夹归档到另一个位置

sql-server - 是否可以在旨在插入数据的存储过程中插入当前日期时间?

java - 如何在java中给出时间戳值作为参数?

PostgreSQL 获取从现在起 24 小时后创建的结果

c - 编写单个生产者/单个消费者队列的最有效方式

linux - Linux上的Shell脚本运行java类

linux - 在没有root权限的情况下更新ldconfig缓存

c++ - 性能测量显示每个函数调用的 malloc 影响?

python - 将 bash shell 替换为 python 程序的 cmdline 界面

c - 实现我自己的 "strings"工具——GNU 字符串找到的缺失序列