I am trying to use grep to match only a specific part of a row in a file.
The file is a huge csv file with some columns containing json with commas so it is hard to figure out which column what I am looking for is.
I am using
egrep -o 'opened for client .*(' filename.csv
and this gives me the full csv rows containing as part of the line the search term, the problem is that I am interested in either capturing the part matched in the .*
or only list the search term and nothing else.
So if I have a row in the csv:
,,,,,opened for client jdoe (P) and details attached,,,,,,
,,,,,opened for client jjunior (P2) and details attached,,,,,,
the empty columns before after are filled with hundreds of other information. Omitting for clarity
I want to print only
I.e. either
opened for client jdoe
opened for client jjunior
etc
or only
jdoe
jjunior
How can I do that?