LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 10-01-2005, 10:09 AM   #1
kornerr
Member
 
Registered: Dec 2004
Location: Russia, Siberia, Kemerovo
Distribution: Slackware
Posts: 893

Rep: Reputation: 35
How to "echo" coloured text?


Thanks.
 
Old 10-01-2005, 10:45 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

Code:
#!/bin/bash

# Escape code
esc=`echo -en "\033"`

# Set colors
cc_red="${esc}[0;31m"
cc_green="${esc}[0;32m"
cc_yellow="${esc}[0;33m"
cc_blue="${esc}[0;34m"
cc_normal=`echo -en "${esc}[m\017"`

echo "Here's ${cc_green}some green text${cc_normal} for you."
echo "Here's ${cc_blue}some green text${cc_normal} for you."
The color codes (0;31 etc) are like those used in dir_colors:

# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white

Hope this helps.
 
Old 10-01-2005, 11:00 AM   #3
kornerr
Member
 
Registered: Dec 2004
Location: Russia, Siberia, Kemerovo
Distribution: Slackware
Posts: 893

Original Poster
Rep: Reputation: 35
Thanks, druuna!

Now I'm able to add coloured echo "Compilation succeeded!" to Makefiles
 
  


Reply

Tags
bash, color, output


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What does echo alias "char-major-10-224 off" >> /etc/modules.conf do? abefroman Linux - Software 2 09-16-2009 11:10 PM
simple "echo > qbc" cron jobs doesn't run shole Linux - Newbie 3 09-23-2006 03:09 PM
"echo 3 > /proc/acpi/sleep" does nothing - ?? achallenger1 Linux - Newbie 6 08-03-2005 12:28 AM
(echo -n "standby" > /sys/power/state) only allowed for root? brynjarh Debian 5 02-14-2005 10:08 AM
want full description of "echo num > / path/...." zameer_india Linux - Newbie 5 01-08-2005 04:10 AM


All times are GMT -5. The time now is 07:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration