3
How can I mark two columns in the middle of text.
grep --color '^[[:alnum:]]*[[:blank:]]' file
This mark text in the beginning, but I want to mark second and third columns. How can pass first one?
3
How can I mark two columns in the middle of text.
grep --color '^[[:alnum:]]*[[:blank:]]' file
This mark text in the beginning, but I want to mark second and third columns. How can pass first one?
1
Try this with GNU grep:
grep --color -P '^[[:alnum:]]+[[:blank:]]+\K[[:alnum:]]+[[:blank:]]+[[:alnum:]]+' file
What 'K' means? I can't find it in man. – diego9403 – 2015-08-23T09:40:59.787
Remove \K
to see the difference. If \K
appears in a Perl Regex (enabled by grep's option -P
), it causes the regex matcher to drop everything before that point from the internal record. – Cyrus – 2015-08-23T09:45:30.513
Suggestion: use
gawk
to add terminal escape sequences to$2
and$3
– cxw – 2015-08-23T09:13:59.360