Is it possible using just one grep and regexp combination to achieve the following. Say I have a file like so:
$ cat f.txt
line 1 foo
line 2 boo
no match
line 3 blank
line X no match
I want to match all the lines that start with the word line and followed by a number but only display the what come after that, so the part that is matched by (.*).
$ grep -E '^line [0-9]+(.*)' f.txt
line 1 foo
line 2 boo
line 3 blank
Can you say match but don’t display this part ^line [0-9]+ like doing the inverse of grep -o '^line [0-9]+'
So my expected output would look like this
$ grep -E ***__magic__*** f.txt
foo
boo
blank
Given your example file:
This is easy with Perl:
Or with sed:
Either case, prints: