作者honercek (Happy Life)
看板Linux
标题Re: [问题] ps + grep
时间Tue Jun 24 12:13:39 2008
※ 引述《everydate (月)》之铭言:
: 请问一下
: 如果我要用 ps 去找某一个行程是否在执行中
: (ex) ps | grep "testprocess"
: 结果会永远会有结果 因为它连这个动作都算进去了
: 5407 root 304 S grep testprocess
: 这样就不能用了 ...
: 如果我先把结果先写到某个档案 ,再去 grep
: ps > tmp.txt
: cat "tmp.txt" | grep "testprocess"
: 这样又会受到长度限制
: 因为我发现只要某一行的长度太长 它就不会完整显示在 tmp.txt
: (ex)
: 605 root 884 S /usr/sbin/runnetwork -a 192.168.0.1 -c /etc/ ..... (後
: 面的都没有了,只印到一半)
: 而我要判断的 key 就这样被切掉了....
: 请问有什麽方法可以解决这问题吗?谢谢 ^^
-v, --invert-match
Invert the sense of matching, to select non-matching lines.
ps | grep "testprocess" | grep -v grep
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.113.235.131