How would I go about colorizing the output of
echo "`tput setaf 1`foo`tput op`" works as expected
echo "foo" | sed -e 's/(foo)/`tput setaf 1`\0`tput op`/g' however, does not.
What am I missing here?
migrated from serverfault.com Dec 4 '12 at 3:06
This question came from our site for professional system and network administrators.
The backticks `` in the echo command spawn a process and it's output is substituted into the echo command line. You can see this with e.g.
This works because the contents of the
The sed command you're using wraps everything in
You can fix this by putting "" around your sed command
You also had an error in your sed command. The
Does it have to be
The above will highlight
To make it print all lines and only highlight