ps grep命令查找

2360阅读 0评论2017-10-17 jsxthncn
分类:LINUX

用ps -def | grep查找进程很方便,最后一行总是会grep自己。
~ # ps | grep telnetd
 1122 root       0:00 telnetd
 1220 root       0:00 grep telnetd

用grep -v参数可以将grep命令排除掉
# ps | grep telnetd | grep -v grep
 1122 root       0:00 telnetd

用awk提取一下进程ID
# ps | grep telnetd | grep -v grep | awk '{print $1}'
1122

用wc -l计算查找的结果数量
# ps | grep telnetd | grep -v grep | wc -l
1


上一篇:wpa_supplicant嵌入式移植与使用
下一篇:mini-xml移植与使用