putting color on output file script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting putting color on output file script
# 1  
Old 03-14-2011
putting color on output file script

do you have any simple script on how to change the color and font of a string in a script example

Code:
 echo "===================================="
    echo "  sample color script"
    echo "===================================="
    echo "  [1] hello "
    echo "  [2] bye"

on [1] hello, wanted to use say red bold color. and use different color as well on [2] bye.

hope you could assist.
# 2  
Old 03-14-2011
You want to include Ansi terminal controls in your script, take a look here for details
# 3  
Old 03-14-2011
The portable way is to use tput: Man Page for tput (Linux Section 1) - The UNIX and Linux Forums

Code:
tput smso ... bold on
tput rmso ... bold off
tput setf 4 ... switch to red
tput serf 1 ... switch ro blue
tput reset ... reset all (slow)

Code:
echo "===================================="
    echo "  sample color script"
    echo "===================================="
    echo "  `tput smso``tput setf 4`[1] hello `tput rmso``tput setf 0`"
    echo "  `tput setf 1`[2] bye`tput setf 0`"


Last edited by hergp; 03-14-2011 at 06:07 AM.. Reason: corrected typo
This User Gave Thanks to hergp For This Post:
# 4  
Old 03-14-2011
MySQL

see the following examples

Code:
 echo -e "\033[33;31m Color Text"

Color Text
Code:
 echo -e "\033[33;32m Color Text"

Color Text
Code:
echo -e "\033[33;33m Color Text"

Color Text
your looking like this or ..?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Emergency UNIX and Linux Support

Disk space script output in color

I'm connecting to 15 servers in using ssh and storing disk space details of each server in a text file Finally , I'm emailing that text file at the particular id using mail -x . The report looks something like this. Filesystem size used avail capacity Mounted on /proc ... (30 Replies)
Discussion started by: ajaypatil_am
30 Replies

2. Shell Programming and Scripting

Need help putting output on one line

Good afternoon, I have been searching the web, and these forums for help. I will try my best to explain the issue, and what my desired results are. I am doing queries in MYSQL, and need the output to be sent to a file. That file needs to have things with the same ID on the same line. To... (14 Replies)
Discussion started by: brianjb
14 Replies

3. Shell Programming and Scripting

Append color in shell script for output

Hi Experts, I want to get my shell script output in a color for a particular word. PFB my output. TT.QM.JTV1S1 TLORSBT2.JMR701T1.C1 REPOS TT.QM.JTV1R1 TLORSBF2.JMR701T1.C1 NORMAL whenever REPOS word comes then entire line should come in red color. Can you please help me... (4 Replies)
Discussion started by: darling
4 Replies

4. UNIX for Dummies Questions & Answers

Putting the Current -date in the Output File

Hi guys, Just want to ask how can I make a script that will perform like this. 1. Execute the command 2. Then the output of the command will be redirected to a file 2. The file that has been created will have a date on it equivalent to the date and time it was created (or maybe after the... (5 Replies)
Discussion started by: rymnd_12345
5 Replies

5. Shell Programming and Scripting

Putting echo output as input to stat

I have a string with escape differentiators as a result of searching for a file using find. Essentially find returned to my shell variable several absolute paths each ending with the file name and each path/file separated by \n. Echo recognizes the escape sequence and is able to print the paths... (3 Replies)
Discussion started by: Ebodee
3 Replies

6. Shell Programming and Scripting

.bashrc/PS1 command color different color to command output

I have been configuring my .bashrc PS1 to be displayed with some nice colors and in a format that I like, however there is one thing that I cannot figure out (or know if it's even possible). my PS1 line is as follows: export PS1='\\u\@\\h\:\\w\n\\$ \'This makes the command and command output... (0 Replies)
Discussion started by: jelloir
0 Replies

7. Shell Programming and Scripting

How to redirect the output to multiple files without putting on console

How to redirect the output to multiple files without putting on console I tried tee but it writes to STDOUT , which I do not want. Test.sh ------------------ #!/bin/ksh echo "Hello " tee -a file1 file2 ---------------------------- $>./Test.sh $> Expected output: -------------------... (2 Replies)
Discussion started by: prashant43
2 Replies

8. Shell Programming and Scripting

Getting command output and putting into newfile

Hello All, I am using the below code: #!/bin/sh /omp/bin/TICLI "op:alarm,all" > filename for getting command output and then putting the output into newfile but the problem is this, that not the complete output goes into newfile and the script stops. for example: if this commands gives... (18 Replies)
Discussion started by: wakhan
18 Replies

9. Shell Programming and Scripting

Putting screen output in a log file

I want to output screen messages to a logfile when executing an automated script. I have tried the script and command to do this but with no luck. Thanks, Nicole (5 Replies)
Discussion started by: nsutti
5 Replies
Login or Register to Ask a Question