ps + grep - Linux

By Audriana
at 2008-06-24T12:13
at 2008-06-24T12:13
Table of Contents
※ 引述《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
--
: 請問一下
: 如果我要用 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
--
Tags:
Linux
All Comments
Related Posts
Xubuntu正體中文版?

By Hedda
at 2008-06-24T11:19
at 2008-06-24T11:19
思科SAN磁盤網路安全架構解決方案

By Zora
at 2008-06-24T05:27
at 2008-06-24T05:27
DAS/NAS/SAN/iSCSI?別再鬧了!

By Susan
at 2008-06-24T05:18
at 2008-06-24T05:18
新手請教ubuntu 8.04

By Agnes
at 2008-06-24T03:30
at 2008-06-24T03:30
CentOS 5.2 released

By Todd Johnson
at 2008-06-24T02:30
at 2008-06-24T02:30