Scenario we are looking for some support process and grep keeps showing up in the results, we want to get rid of that

So here is the original way:

ps auxwww | grep support

Here is the simple way to remove it (but its also not pretty):
ps auxwww | grep support | grep -v support

Other ways:
ps auxwww | grep [s]upport
ps auxwww | grep '[s]upport' ## looks for support, but in the ps output we get [s]upport which we are not looking for
ps auxwww | grep -E 'sup()port' ## looks for support, but in the ps output we get sup()port which we are not looking for. needs egrep or grep -E
ps auxwww | grep -E 's()u()p()p()o[r]t' ## also works need egrep or grep -E
ps auxwww | grep 'sup\(\)port' ## without it you need to escape ()
ps auxwww | grep 'sup()port' ## fails
ps auxwww | grep -E '()support' ## doesnt work, cant put () at end or front
ps auxwww | grep -E 'support()' ## doesnt work, cant put () at end or front
ps auxwww | grep '\(\)support' ## doesnt work, cant put () at end or front
ps auxwww | grep -E 'suppor()t'
ps auxwww | awk '/support/' ## fail-ish, returns the awk
ps auxwww | awk '/support/ && ! /awk/' ## get the awk to not return
ps auxwww | awk '/sup()port/' ## similar to grep method
ps auxwww | awk '/[s]upport/'

NOTE: lines with comment fail and fail-ish should not be used

One thought on “Removing Grep or Awk from search results (example with PS)

Leave a Reply

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