例如,我尝试过top | grep skype,但它不起作用。我正在尝试通过名称查找特定的进程。
发布于 2011-09-21 22:07:47
改用这个:ps -ax | grep -i skype
发布于 2011-09-21 22:18:25
用法:top -l 0 | grep Skype
0表示无限样本。您还可以将样本数量限制为正数。
发布于 2013-10-01 20:49:10
在Linux上,top命令支持-p选项来监视特定的PID。在MacOS上,-p选项称为-pid。
# Get the PID of the process
pgrep Skype
# Then
top -pid <put PID here>
# Or more succinctly:
top -pid `pgrep Skype`如果您经常这样做,您可以将其转换为函数并将其添加到~/.bash_profile中
# Add this to ~/.bash_profile
function topgrep() {
if [[ $# -ne 1 ]]; then
echo "Usage: topgrep <expression>"
else
top -pid `pgrep $1`
fi
}现在,您可以简单地使用topgrep Skype,它将像往常一样运行,但它将只显示与expression匹配的进程。
https://stackoverflow.com/questions/7501057
复制相似问题