PDA

View Full Version : Linux: How to find several/multiple strings/phrasses in file



Fli
11-25-2014, 04:16 PM
What are best linux command to find multiple phrasses in a file?
while these phrasses contians symbols like: ; * / \ " ? ' , . ! < ... ?

i found some commands but i dont guarantee it will find all the phrasses or work:


grep 'string1\|string2' filenameegrep "Ethernet|Bcast"
grep -E 'foo|bar' *.txt
grep -e foo -e bar *.txt

i think many of these special characters needs to be commented out by "\" but it may not work properly.

Another thing is to use "grep -F phrasses_file.txt file_to_examine.php"
phrasses_file.txt contains one phrasse per line..