2008年3月28日金曜日

Substitute regexp for -v option

When you check the running processes with ps command and select the target processes only with grep command, it is not a cool solution to do like following.
ps -ef | grep hoge | grep -v grep

Doing like this gives the same result.
ps -ef | grep [h]oge

Because regexp like /[h]oge/ matches "*hoge*" and does not match "[h]hoge" that is the argument of grep command.

0 件のコメント: