Linux Search text in files: grep

Linux Search text in files: grep

Search the console for the contents of specific files.

Search all files

The following command searches the contents of all files including files in subfolders:

grep -r SEARCHSTRING *

Search specific files

The following command searches the contents of all files with extension .php incl. files in the subfolders

find . -name *.php -exec grep -l SEARCHSTRING {} \;

Search specific files in specific folders

The following command searches the contents of all files with extension .php in folders that contain test in their name

find . -path *test* -name *.php -exec grep -l SEARCHSTRING {} \;
rate:
rate this post positively
(3)
rate this article negatively
(0)

Questions / Comments


Thank you! We well check your comment as soon as possible


 
By continuing to browse the site, you agree to our use of cookies. More Details