Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有人可以帮我解析这个输出以显示总分钟数吗?
这是命令(除了格式之外,它按预期工作):
ps -eo pid,etime,command | grep some_process | grep -v grep | awk '{print $2}'
输出(以小时、分钟、秒为单位)
03:01:24
我需要输出看起来像:
181.40
(3 小时 1 分 24 秒显示为实数)
这可能吗?非常感谢任何建议。
ps -eo pid,etime,command | grep PID | grep -v grep | awk '{print $2}' | awk -F : '{ printf("%.2f\n", $1*60+$2+($3/60)); }'
;)
编辑: 改进版本(谢谢@alexandernst 和@Nathan):
ps -eo pid,etimes,command | grep PID | grep -v grep | awk '{printf("%.2f\n", $2/60)}'