トップ出力からPWD列を取得できますか?

トップ出力からPWD列を取得できますか?

わかりましたpwdx。しかし、PWDが表示されたらいいと思いますtop。つまり、PWDとCPU/memの使用量を並べてみたいと思います。top/の出力psと定期的な更新をpwdx組み合わせるスクリプトや1行のスクリプトを持っている人がいますか?

ベストアンサー1

私のオタクの解決策は次のとおりです。

ps --no-headers -e -o pid,%cpu,%mem,args | grep -v "ps --no-headers" > ps.txt && awk '{ print $1 }' ps.txt > pids.txt && cat pids.txt | xargs pwdx | cut -d ' ' -f 2 > pwd.txt && awk '{ print " "$1" "$2" "$3" "}' ps.txt > ps1.txt && cut -d ' ' -f 4- ps.txt > ps2.txt && paste ps1.txt pwd.txt ps2.txt

ファイルを書かなくても大丈夫ですか?それとも一般的に悪夢が少ないのですか?

おすすめ記事