How do I find all files containing specific text on Linux
This command will help us find all files which contain specific text on Linux:
grep -rnl "/var/path/samplefolder" -e "sampletext"
If you would like to know what that line looks like and get the line number, use the following command:
grep -rnw "/var/path/samplefolder" -e "sampletext"
-r is recursive
-n is line number
-l (lowercase L) returns the file name which contains the text you need
-w gives the line which contains the whole matching word