simple examples of how to

Thursday, October 20, 2011

[Linux] Color texts in echo

echo -e "\033[your message\033[0m"

eg. echo -e "\033[31mhello, echo world\033[0m"
where 31m is for red color

here goes the color code:

31m : red
32m : green
33m : yellow
34m : blue
35m : violet
36m : cyan
37m : white

you can also make it bold with adding 1; like the following

eg. echo -e "\033[1;31mhello, echo world\033[0m"

The above coloring generally works in every shell-print commands including awk, python, etc

for python: print "\033[1;31mhello, echo world\033[0m"
for awk: print "\033[1;31mhello, echo world\033[0m"


more info: http://www.freeos.com/guides/lsst/misc.htm

No comments:

Post a Comment