Need help with using sed or grep

cchen

Diamond Member
Oct 12, 1999
6,062
0
76
Ok, I have a file with various lines of text. On each line, want to extract the text after the first period and before the next period. Here's an example of one line of text:
3:30 AM A King in New York (1957) A European king loses his money while stranded in the US. Charles Chaplin, Michael Chaplin, Dawn Addams. D: Charles Chaplin. BW 100m.

so I would want to grab Charles Chaplin, Michael Chaplin, Dawn Addams

I can't figure out how to do this using sed or grep, and I've tried looking up a few examples but no dice

Can anyone help?
 

xcript

Diamond Member
Apr 3, 2003
8,257
1
81
You could do it like so with sed:

sed 's/[^.]*.\([^.]*\).*/\1/'

But it's a bit easier with awk :):

awk -F. '{ print $2 }'
 

cchen

Diamond Member
Oct 12, 1999
6,062
0
76
Originally posted by: xcript
You could do it like so with sed:

sed 's/[^.]*.\([^.]*\).*/\1/'

But it's a bit easier with awk :):

awk -F. '{ print $2 }'

could you please explain how the regex you used for sed? this is all so confusing :confused: