Sometimes we need to ignore multiple lines with certain words and get the list out of the file. usually it will be a log file to read . The below grep command can be used to ignore multiple words present in a text file.
Lets say the file contain
$ cat list.txt
apple
orange
apple
banana
papaya
Now we need to ignore line with orange , banana and papaya . So we can use the below grep command.
$ cat list.txt | grep -Ev "orange|banana|papaya"
apple
apple
It will ignore lines with the words in -v part of grep.
Comments
Post a Comment