How to Use egrep to Find Multiple Strings in a File?
Below is the example to find multiple strings in a file using the egrep command in Linux or Unix environment.
To specify a particular file, you can specify the name instead of *.txt. For example:
egrep Command to Find Multiple Strings in a File
In the following example, the egrep command will look for strings Scott, Smith and Phillip in all text files.egrep 'Scott|Smith|Phillip' *.txt
Output:
emp.txt:1200|Scott|Technology|5500 emp.txt:9500|Smith|Technology|6000 emp.txt:9548|Phillip|IT|8000
To specify a particular file, you can specify the name instead of *.txt. For example:
egrep 'Scott|Smith|Phillip' emp.txt
Comments
Post a Comment