Home > Mobile >  Sed to add color to column for a specific pattern?
Sed to add color to column for a specific pattern?

Time:06-18

I figured out how to colorize column 3 in green like this:

green=$'\033[1;32m';off=$'\e[m';echo -e "num co1umn1 column2 column3\n=== === === ===\n1 this is me\n2 that is you"|column -t|sed "s/[^[:blank:]]\{1,\}/$green&$off/3";unset green off

enter image description here

CodePudding user response:

One way to do this is to ignore the first two lines of the output in sed:

sed "1,2 ! s/[^[:blank:]]\{1,\}/$green&$off/3";
  • Related