How To Search Inside Files Via The Terminal in Linux

image_pdfimage_print
find ./ -name “*.ext” -print | xargs grep “keyword”

In the command given above, you have to change “.ext” with the file extension you are going to search inside, then replace “keyword” with text you want to search.

Here is an example:

find ./ -name “*.php” -print | xargs grep “

–> This command will search inside the current folder all PHP files for this code: “”.

Here is another example:

find ./ -name “*.txt” -print | xargs grep “How to unlock”

–> This command will search all text files under the current folder for this keyword: “How to unlock“.