Find Files

Find files that contain a text string:

grep -lir "some text" *

The -l switch outputs only the names of files in which the text occurs (instead of each line containing the text), the -i switch ignores the case, and the -r descends into subdirectories. (found here)

Find files from a list of files, like: find all .htaccess files that contain the string ‘RemoveType’:

find -name '.htaccess' | xargs grep -li "RemoveType"

Find all files that don’t contain a certain string:

grep -Lir "some text" *

An uppercase “L” replaces the lowercase one from the example above.

Leave a Reply