I'm just trying to figure out how to get everything after the first two words in a line. Right now, I've got the opposite - the first two words themself:

^(\S+ \S+)

I want the opposite of this.

Thanks!

Recommended Answers

I would suggest something other than grep in this case.
If you know the the delimeter is definitely a single space, you may use cut, otherwise use awk.

Example input (t.t):

one two three four five six
one two three four five six
one two three four five six
one …
Jump to Post

All 2 Replies

IIRC, the option is '-A <# of lines that follow>"
Example grep -A2 findthistext /opt/inthisfile

I would suggest something other than grep in this case.
If you know the the delimeter is definitely a single space, you may use cut, otherwise use awk.

Example input (t.t):

one two three four five six
one two three four five six
one two three four five six
one two three four five six
one two three four five six

Using cut:

$ cut -d' ' -f 3- t.t
three four five six 
three four five six 
three four five six 
three four five six 
three four five six 

Using awk:

$ awk '{ s = ""; for (i = 3; i <= NF; i++) s = s $i " "; print s }' t.t
three four five six 
three four five six 
three four five six 
three four five six 
three four five six 
commented: I like this solution +6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.