Re: [問題] ps + grep
※ 引述《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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):