linux find 搜尋檔案內容

我們要找一個log內容,就可以用這個方式找

find {path} -name {name} exec grep -H {要搜尋的字串}” {} \;

例如要找檔案內的 Undefind index

find “/var/logs/php-fpm/” -name “*.log” -exec grep -H “Undefined index” {} \;

你也可以進到目錄內找

find . -name “*.log” -exec grep -H “Undefined index” {} \;

發佈留言