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)); }'
;)
編集: 改善されたバージョン(thx @alexandernstおよび@Nathan):
ps -eo pid,etimes,command | grep PID | grep -v grep | awk '{printf("%.2f\n", $2/60)}'