How can you write the command using egrep without the -v option? With great difficulty. All you have to do is create an ERE that matches any line that does not match any line that contains something like CAT, MAT, or DAT. How you define "something like" may make a huge difference between this being difficult or impossible.
If this isn't a homework assignment (which would need to be filed in the Homework and Coursework Questions forum instead of the Shell Programming and Scripting forum), why would you need to avoid the egrep -v option?
Thanks for response. Actually I have multiple conditions in my egrep to look out for pattern like
line starting with a certain string, spaces at some point, numbers at somepoint, ending with some characters. excluding few strings is one such condition
So I cannot use -v.
This requirement came in for my work Not for assignment.
For matching condition, I can use this
egrep (CAT|MAT|DAT) test.txt
but to negate this, I tried all options like using (^) but couldnt get it.
---------- Post updated at 01:54 PM ---------- Previous update was at 01:54 PM ----------
Thanks for response. Actually I have multiple conditions in my egrep to look out for pattern like
line starting with a certain string, spaces at some point, numbers at somepoint, ending with some characters. excluding few strings is one such condition
So I cannot use -v.
This requirement came in for my work Not for assignment.
For matching condition, I can use this
egrep (CAT|MAT|DAT) test.txt
but to negate this, I tried all options like using (^) but couldnt get it.
If really don't want to use -v option with egpre or grep to exclude the lines containing CAT|MAT|DAT strings, then as per my knowledge the best option to use is sed