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?

diego9403
  • 907

1 Answers1

1

Try this with GNU grep:

grep --color -P '^[[:alnum:]]+[[:blank:]]+\K[[:alnum:]]+[[:blank:]]+[[:alnum:]]+' file
Cyrus
  • 5,581
  • What 'K' means? I can't find it in man. – diego9403 Aug 23 '15 at 09:40
  • 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 Aug 23 '15 at 09:45