In this example, we would like to show how in Bash find files that contain some specific text.
Quick solution (run in the command line):
grep -r -F "text to find" /path/to/directory # or grep -rl -F "text to find" /path/to/directory
-rmeans recursive searching,
-lmeans listing file names only (without found text),
-Fmeans simple string mode searching,
/path/to/directoryindicates searched directory
(can be removed to search current directory, e.g.
grep -r -F "text to find").
- to use case insensitive execute with
grep -ri -F "text to find" /path/to/directory
grepversions may do not support
As a practical example, we would like to show looking for
org string inside
~/test directory with line printing that contains the string.
$ grep -r -F "org" ~/test/ /home/john/test/sub-test/test-2.txt:Some organisation .... /home/john/test/sub-test/test-1.txt:https://test.org /home/john/test/search.txt:organic search: 79%
|Found file||Found line|