What is the difference between
ps -ef | grep WDA
and
ps -ef | grep [W]DA
How exactly [] rids of the unwanted info?
What is the difference between
ps -ef | grep WDA
and
ps -ef | grep [W]DA
How exactly [] rids of the unwanted info?
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.
pgrepcan likely replaceps ... | grep ...and thatpgrepis clever enough to not match itself. – thrig Jul 09 '17 at 13:46