![輔助 | grep config 與 ps aux | grep config 對比grep "conf[g]"](https://rvso.com/image/95511/%E8%BC%94%E5%8A%A9%20%7C%20grep%20config%20%E8%88%87%20ps%20aux%20%7C%20grep%20config%20%E5%B0%8D%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 命令過程。