top
-p
オプションと複数のPIDを使用して実行しようとしています。xargs
。ただし、top
実行に失敗してエラーが発生しますtop: failed tty get
。
$ pgrep gvfs | paste -s -d ',' | xargs -t top -p
top -p 1598,1605,1623,1629,1635,1639,1645,1932,2744
top: failed tty get
実行される完全なコマンドを表示するには、-t
オプションを使用します。xargs
ビューは良く見え、手動で正常に実行できます。
top -p 1598,1605,1623,1629,1635,1639,1645,1932,2744
しかし、では実行されませんxargs
。なぜそんなことですか?
ベストアンサー1
対話型アプリケーション--open-tty
の場合(例:xargs
top
manxargs:
-o, --open-tty
Reopen stdin as /dev/tty in the child process before
executing the command. This is useful if you want xargs
to run an interactive application.
実行するコマンドは次のようにtop
する必要があります。
pgrep gvfs | paste -s -d ',' | xargs --open-tty top -p