Page 1 of 1

Grep ps – How to exclude the "grep ps" itself from the output?

Grep ps – How to exclude the "grep ps" itself from the output?

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
Examples: "MacOS X - Your question", "MS Word - Your Tip or Trick".

Please note that switching to another language when reading a post will not work!
Posts will not have a translated counterpart.




RSS Feed

Home Forums Software Linux Software Grep ps – How to exclude the "grep ps" itself from the output?

Tagged: , , ,

This topic contains 0 replies, has 1 voice, and was last updated by  hans 5 years, 8 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • 2619

    hans
    Keymaster

    I often play in a shell with the ps/grep combo, like this one:

    ps -ax | grep whatever

    The result will show the grep statement as well. With a simple trick, you can exclude the grep statement in the output:

    ps -ax | grep [w]hatever

    (Square brackets around the first character – this will match lines containing “whatever”, which grep ‘[w]hatever’ does not)

Viewing 1 post (of 1 total)



You must be logged in to reply to this topic.