Reputation: 1865
Searched and cant find a similar question to this:
I am trying to use egrep on a file like the following:
ABCD(something): Some very good code;
ABCD(somethingElse): Some other very good code;
ABCD(somethingElseElse): Some other very good code;
I want to produce output like the following:
Some very good code;
Some other very good code;
Some other very good code;
I am using the following grep command:
egrep -RIn --color "ABCD(.+):" grep_log_test.txt
Which works but is also outputting the matched pattern. How can I exclude the pattern from the output? I see the -o option but that just prints the patten match only...
Upvotes: 1
Views: 689
Reputation: 6449
As I've mentioned in the comments above, sed is probably the best and easiest tool to use here, as in:
sed 's/ABCD(.\+): *//'
It uses the s
command to match ABCD(.\+): *
between first set of slashes and replace it with (empty string) between second set of slashes.
Upvotes: 1