Linux Find in Files

Just for easy reference...

grep

grep -r "Search String" dir/ grep -inr --include \*.log --include \*.dat "Bananas" ./
-r: recursively

-i: ignore-case

-n: each output line is preceded by its relative line number in the file

--include \*.log: all *.log files
(escape with \ just in case you have a directory with asterisks in the filenames)

./: Start at current directory.

find

find . -print0 | xargs -0 grep 'Search String' -sl

PHP files only...

find . -iname '*php' -print0 | xargs -0 grep 'Search String' -sl

Case insensitive double search... (grep -Z is like find -print0)

find . -print0 | xargs -0 grep '_POST' -sliZ | xargs -0 grep 'query' -sli