![辅助 | grep config 与 ps aux | grep config 对比grep "conf[g]"](https://linux22.com/image/95511/%E8%BE%85%E5%8A%A9%20%7C%20grep%20config%20%E4%B8%8E%20ps%20aux%20%7C%20grep%20config%20%E5%AF%B9%E6%AF%94grep%20%22conf%5Bg%5D%22%20.png)
我想知道为什么在输出中ps aux | grep
包含该命令但没有。grep
ps aux | grep "confi[g]"
$ 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
与
$ 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
答案1
因为grep "confi[g]"
命令搜索“配置”字符串,在第二种情况下,该grep "confi[g]"
命令不包含“配置”细绳。它包含“配置[g]”细绳。
ps
这是一个常用的 grep 技巧,以避免在输出中搜索时打印 grep 命令过程。