Limit the output of the TOP command to a specific process name

后端 未结 17 2637
臣服心动
臣服心动 2020-12-12 09:48

If you call the top command, you get all the running processes. But how can I limit the output only to a certain process name like \"java\"?

I\'ve

17条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 10:11

    Using the answer from here I was able to create a one liner

    top -pid $(pgrep process_name | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ -pid /g')
    

    This works for me on MacOS 10.12 (Sierra)

提交回复
热议问题