Mar 21

How to search inside files on linux

Tag: ubuntutengo @ 5:37 pm

On Linux, searching for files is easy with the find command. In order to search for a specific text pattern inside a file you can use this command:

find . -name ‘*.php’ -exec grep ‘my text pattern’ {} \;

the “-name” section limits the search to files matching the stated pattern, in this case only *.php files.
The “-exec” section executes the grep command for every matching files - here it uses grep to search inside the files and look for the specified pattern “my text pattern”.


Random Posts

Leave a Reply