file system

How to find a particular text string in Linux

You need to use the grep command. The grep command searches the given input FILEs for lines containing a match or a text string.

grep command syntax

The syntax is:

grep "text string to search" directory-path

or

grep [option] "text string to search" directory-path

or

grep -r "text string to search" directory-path

or

grep -r -H "text string to search" directory-path

or

egrep -R "word-1|word-2" directory-path

or

egrep -w -R "word-1|word-2" directory-path