Neat grep Trick

Have you ever typed this into a terminal?

ps ax | grep someproc | grep -v grep

Try this instead next time:

ps ax | grep '[s]omeproc'

This little trick adds extra characters to the actual grep command that will show up in the ps output. However, those characters will be interpreted as a character class by grep itself which will search for the intended ‘someproc’.

The difference in the command string will cause it to be omitted in the results without adding that extra grep! 😀

Leave a Reply

Your email address will not be published. Required fields are marked *