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
ilkkachu
  • 138,973
c4f4t0r
  • 649

1 Answers1

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.

zuazo
  • 3,042