1

I would like to know why ps aux | grep includes the grep command in the output but ps aux | grep "confi[g]" does not.

$ ps aux | grep config
root               50   0.0  0.0  2548368   5760   ??  Ss   14Sep16   0:29.27 /usr/libexec/configd
emesa           20534   0.0  0.0  2434840    796 s002  S+    4:41PM   0:00.00 grep config

vs.

$ ps aux | grep "confi[g]"
root            15776   0.0  0.0  2519824    940   ??  Ss   Tue11AM   0:00.08 /System/Library/PrivateFrameworks/SystemAdministration.framework/XPCServices/writeconfig.xpc/Contents/MacOS/writeconfig
root               50   0.0  0.0  2547320   5740   ??  Ss   14Sep16   0:29.27 /usr/libexec/configd
2

1 Answer 1

2

Because grep "confi[g]" command searches for the "config" string and in your second case the grep "confi[g]" command does not contain the "config" string. It contains the "confi[g]" string.

It's a commonly used grep trick to avoid printing the grep command process when searching in ps output.

1
  • 1
    Commonly used if one doesn't know about pgrep ... (or are stuck using legacy or proprietary unixen) Sep 29, 2016 at 17:48

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