grep -o
grep 忽略匹配自己 ps aux | grep python 總是會看到一個包含grep的匹配項,這是不符合我們的匹配期望的。可以這樣過濾掉grep這個匹配項。可以用下面這個命令來實現
ps aux | grep python | grep -v grep
grep -F
grep -F 等價於 fgrep。 egrep 等價於 grep -E。
下面是找到的資料
You have a file with a list of say ten Unix usernames in plain text. You want to search the group file on your machine to see if any of the ten users listed are in any special groups:
grep -F -f user_list.txt /etc/group
The reason the -F switch helps here is that the usernames in your pattern file are interpreted as plain text strings. Dots for example would be interpreted as dots rather than wild-cards. -f 表示內容從 user_list.txt 中讀取。
grep -o
grep -o 輸出匹配的內容。
grep -E
支持擴展的正則表達式。