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!
Jump to PostI would suggest something other than
grep
in this case.
If you know the the delimeter is definitely a single space, you may usecut
, otherwise useawk
.Example input (
t.t
):one two three four five six one two three four five six one two three four five six one …
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, learning, and sharing knowledge.
You're trying to visit a URL that doesn't currently exist on the web. Most likely, a member posted a link a long time ago to a web page that has since been removed. It's also possible that there was a typo when posting the URL. We redirect you to this notice instead of stripping out the link to preserve the integrity of the post.