LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-20-2008, 09:02 AM   #1
skyknight
LQ Newbie
 
Registered: Sep 2008
Posts: 17

Rep: Reputation: 1
Output Text in color, in console


I want to get `echo xxx` output in color, what I have to do for that?

Thanks.
 
Old 11-20-2008, 09:20 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,503

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
You have to use the -e option of echo and the proper escape sequence. The Advanced Bash Scripting Guide explains it all, section 33.6. Also look at the Bash Prompt HOWTO. Some useful information there and the following script to demonstrate:
Code:
#!/bin/bash
#
#   This file echoes a bunch of color codes to the 
#   terminal to demonstrate what's available.  Each 
#   line is the color code of one forground color,
#   out of 17 (default + 16 escapes), followed by a 
#   test use of that color on all nine background 
#   colors (default + 8 escapes).
#

T='gYw'   # The test text

echo -e "\n                 40m     41m     42m     43m\
     44m     45m     46m     47m";

for FGs in '    m' '   1m' '  30m' '1;30m' '  31m' '1;31m' '  32m' \
           '1;32m' '  33m' '1;33m' '  34m' '1;34m' '  35m' '1;35m' \
           '  36m' '1;36m' '  37m' '1;37m';
  do FG=${FGs// /}
  echo -en " $FGs \033[$FG  $T  "
  for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
    do echo -en "$EINS \033[$FG\033[$BG  $T  \033[0m";
  done
  echo;
done
echo
 
Old 11-21-2008, 01:39 AM   #3
skyknight
LQ Newbie
 
Registered: Sep 2008
Posts: 17

Original Poster
Rep: Reputation: 1
Thanks for your resons... It is very helpful....

Is there any possiblities for modifying the console text area.... like I want to have a constant line at the top of all my consoles where i can display battery power, time etc...
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Constantly changing text color on the console jpanski Linux - Newbie 2 01-09-2008 02:35 PM
Meaning of text color in the console? (ls output for example) EtherGhost Linux - General 3 12-31-2006 12:59 AM
Console Text Color Change Mercurius Slackware 6 05-16-2006 07:35 AM
How to get a color text console? dejavu_01 Debian 1 08-30-2005 11:38 AM
Different color for console error output? ta0kira Linux - Software 0 05-18-2005 07:22 AM


All times are GMT -5. The time now is 09:54 AM.

Main Menu
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