問題
當ubuntu中,想查找一個詞語在哪個檔案裡出現過, 用什麼指令呢?
解決方法
1 在目前路徑下全檔案查找任何檔案中包含的s:
grep -r "s" *
2 在檔案a中查找s并且顯示行号:
grep -nr "s" a
3 執行個體
[email protected]:~/Downloads$ grep -r "s" * //全路徑搜尋,不顯示行号
Binary file .v.c.swp matches
Binary file sogoupinyin_2_i386().deb matches
a:s
a:as
a:s
a:pasfas
Binary file sogoupinyin_2_i386.deb matches
Binary file sogoupinyin_2_amd64.deb matches
Binary file .a.c.swp matches
[email protected]:~/Downloads$ grep -nr "s" * //全路徑搜尋,并且顯示行号
Binary file .v.c.swp matches
Binary file sogoupinyin_2_i386().deb matches
a::s
a::as
a::s
a::pasfas
Binary file sogoupinyin_2_i386.deb matches
Binary file sogoupinyin_2_amd64.deb matches
Binary file .a.c.swp matches
[email protected]:~/Downloads$ grep -r "s" a //在檔案a中搜尋s,不顯示行号
s
as
s
pasfas