Reputation: 527
I need to color lines that start with #
.
I have following code in perl, which works fine:
echo 'aaa\n#bbb\nccc' | perl -pe "s/(#.*)$/\e[0;32m\1\e[0m/"
I am trying to do the same in sed, but it just prints the color codes, instead of the color:
echo 'aaa\n#bbb\nccc' | sed -r "s/(#.*)$/\e[0;32m\1\e[0m/"
aaa
e[0;32m#bbbe[0m
ccc
Why are the color codes not working in sed, and what do I have to do differently ?
Upvotes: 1
Views: 63
Reputation: 371
Use '\o033' instead of '\e':
$ echo -e 'aaa\n#bbb\nccc' | sed -r "s/(#.*)$/\o033[0;32m\1\o033[0m/"
Upvotes: 1