Skip to content
Advertisement

4 lines invert grep search in a directory that contains many files

I have many log files in a directory. In those files, there are many lines. Some of these lines contain ERROR word.

I am using grep ERROR abc.* to get error lines from all the abc1,abc2,abc3,etc files.

Now, there are 4-5 ERROR lines that I want to avoid.

So, I am using

JavaScript

This works fine. But when I insert 1 more string,

JavaScript

it doesn’t get affected.

I need to avoid 4-5 strings.. can anybody suggest a solution?

Advertisement

Answer

You are using multiple search pattern, i.e. in a way a regex expression. -E in grep supports an extended regular expression as you can see from the man page below

JavaScript

So you need to use the -E flag along with the -v invert search

JavaScript

An example of the usage for your reference:-

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement