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!
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!
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
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.