PDA

View Full Version : [all variants] alittle bash help



ja660k
December 25th, 2008, 06:06 AM
hey guys, i have a simple i mean real simple bash script, that just tells me the time and date.

but i have echo "XXXXXX" and im wondering if i can change the color of the string im trying to display. instead of it being the default colour of the terminal?

croto
December 25th, 2008, 06:32 AM
Hi, what you need is to tell the console to change colors, which is done through xterm color codes. I googled it and this was the first result:
http://www.frexx.de/xterm-256-notes/.

An example of what you can do is:


echo -e "\033[1;31m$(date)\033[0m"


where the first escape sequence: \033[1;31m sets the foreground color to red, and the last sequence: \033[0m resets the terminal defaults.

ja660k
December 25th, 2008, 07:32 AM
perfect, thankyou i didnt even know what to look for