3

What is the difference between

ps -ef | grep WDA 

and

ps -ef | grep [W]DA

How exactly [] rids of the unwanted info?

1
  • 3
    Usual reminder that pgrep can likely replace ps ... | grep ... and that pgrep is clever enough to not match itself.
    – thrig
    Jul 9, 2017 at 13:46

1 Answer 1

3

WDA is a regular expression that matches itself. Thus the output will sometimes include the process listing for the grep process.

[W]DA is a regular expression that does not match itself. Thus the output will not include the process listing for the grep process.

Further reading

0

Not the answer you're looking for? Browse other questions tagged .