%20%E4%B8%AD%E5%82%B3%E5%9B%9E%E9%8C%AF%E8%AA%A4%E8%A8%8A%E6%81%AF.png)
我需要在資料夾結構中搜尋特定字串。
文件系統包含多個文件,但我只需要檢查 XML 文件。
我搜尋並嘗試了 Linux 遞歸搜尋的命令,但它不起作用。我從命令中得到以下輸出
$ grep -rio --include=*.xml "invokeAction" .
grep: No match.
$ grep -riwc "invokeAction" *
grep: <.Lists all the file Names recursively.>: No such file or directory
$ grep -ir invokeAction *.xml
grep: <.Lists all the file Names.>: No such file or directory
請幫忙。
我需要搜尋
String: "invokeAction"
Mode: Word Only
Directory: Current Directory Recursively
答案1
這將從路徑中遞歸搜尋所有 python 檔案 (*.py) 並在每個檔案上執行 grep -l import
find /path/To/Seach -iname \*.py -exec grep -l import {} \;