2

What is the difference between

ps -ef | grep WDA 

and

ps -ef | grep [W]DA

How exactly [] rids of the unwanted info?

  • 3
    Usual reminder that pgrep can likely replace ps ... | grep ... and that pgrep is clever enough to not match itself. – thrig Jul 9 '17 at 13:46
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

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.