When listing
processes (
via ps or other) and
piping to
grep for one particular process matching a
regular expression, people will often pipe the output to '
grep -v grep' (-v option returns lines that
don't match
regular expression) to make sure
grep doesn't find itself, as in the following:
$ ps ax | grep nslookup
26363 ttyp8 S 0:00 nslookup
26365 ttyp8 S 0:00 nslookup
26366 ttyp8 S 0:00 nslookup
26367 ttyp8 S 0:00 nslookup
26368 ttyp8 S 0:00 nslookup
31337 ttyp9 S 0:00 grep nslookup
What was expected was a listing of all 'nslookup's running on the system, but the actual grep for these processes found itself as a running process. Here's an example of grep -v grep in action:
$ ps ax | grep nslookup | grep -v grep
26363 ttyp8 S 0:00 nslookup
26365 ttyp8 S 0:00 nslookup
26366 ttyp8 S 0:00 nslookup
26367 ttyp8 S 0:00 nslookup
26368 ttyp8 S 0:00 nslookup
Some would argue this is a pointless use of grep.