尋找包含特定字串的所有 .htaccess 檔案?

尋找包含特定字串的所有 .htaccess 檔案?

在我的情況下,如何找到包含特定字串(“common.php”)的所有 .htaccess 檔案(從目前資料夾遞歸)?

這樣做的命令是什麼?

答案1

如果您的外殼是zshbash

grep 'common\.php'  **/.htaccess

**擴展到任意深度的子目錄。)

答案2

該命令將搜索全部文件在該字串的目前目錄中:

grep -r "common.php" .

這樣做的好處是它給出了檔案名稱 - @Rmano 的答案可能會更好。

這將搜尋該.htaccess文件,然後對其運行 grep。

find . -type f -iname '.htaccess' -exec grep -r "common.php" {} \;

答案3

find . -name '.htaccess' -print | xargs grep 'common.php'

相關內容