How can I mark two columns in the middle of text

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

Posted 2015-08-23T08:26:26.113

Reputation: 807

Suggestion: use gawk to add terminal escape sequences to $2 and $3 – cxw – 2015-08-23T09:13:59.360

Answers

1

Try this with GNU grep:

grep --color -P '^[[:alnum:]]+[[:blank:]]+\K[[:alnum:]]+[[:blank:]]+[[:alnum:]]+' file

Cyrus

Posted 2015-08-23T08:26:26.113

Reputation: 4 356

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