Have you ever tried to grep for a process, and saw grep show up too? annoying, right?
$ ps aux | grep "python" |
Well, turns out Wayne Werner found a cool solution!
$ ps aux | grep "[p]ython" |
How does it work? By putting the brackets around the letter and quotes around the string, you search for a regex which says - “Find the character ‘p’ followed by ‘ython’”
But since you put the brackets in the pattern p
is now followed by ]
, grep won’t show up in the results list. Why? because its text is “grep -color [p]ython” and not “grep -color python”.