Suppose my text file with the following strings:
Apple foo foobar
Banana foo foobar1 abc b c
Orange barfoo
Pear foo
How do I group the strings that comes after Apple
, Banana
, Orange
, and Pear
?
I could do this for Apple
, but this wouldn't work for the rest of the text files.
sed 's/\([^ ]*\) \([^ ]*\) \([^ ]*\)/\2 \3/'
I want the output to look like this:
foo foobar
foo foobar1 abc b c
barfoo
foo
Is there a general case where I can print these strings after the first whitespace?