3

What is the difference between

ps -ef | grep WDA 

and

ps -ef | grep [W]DA

How exactly [] rids of the unwanted info?

Den.Den
  • 31
  • 3
    Usual reminder that pgrep can likely replace ps ... | grep ... and that pgrep is clever enough to not match itself. – thrig Jul 09 '17 at 13:46

1 Answers1

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

JdeBP
  • 68,745