Instead of this tired old command line trope:
ps -ef | grep foo | grep -v grep
try this:
ps -ef | grep '[f]oo'
This works because the regex [v]im contains a character class matching the single letter v. This will match the string vim in the ps output, but will not match the grep, i.e. the character class [v] does not match the string [v].$ ps -ef | grep vimdg 14823 14739 0 15:12 pts/0 00:00:00 grep vimdg 21295 13905 0 Nov09 pts/0 00:00:01 vim -R main.c$ ps -ef | grep vim | grep -v grepdg 21295 13905 0 Nov09 pts/0 00:00:01 vim -R main.c$ ps -ef | grep '[v]im'dg 21295 13905 0 Nov09 pts/0 00:00:01 vim -R main.c
No comments:
Post a Comment