Changing font and color in log file of Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Changing font and color in log file of Script
# 1  
Old 09-08-2006
Changing font and color in log file of Script

Hi,

We have process log with user defined error messages and information echos. I wanted to highlight error messgaes in that log file while writing in it. Is there any option with either echo or any other command which enables making text bold or we can change the font of body text of echo.

Any help is appreciated.

Satish
# 2  
Old 09-12-2006
there is escape sequence defined which can be used with echo
Code:
\033[0m Normal characters
\033[1m  Bold
\033[4m   underlined
\033[5m  Blinking
\033[7m  Reverse video

copy below lines into script and redirect output to file.
Code:
echo "\033[1m this a bold message\033[0m"
echo this is a normal message
echo "again normal"
echo "\033[1m again bold\033[0m"
echo "\033[7m reverse set ok\033[0m"

# 3  
Old 09-20-2006
Hi Dhruva,

Thanks for the help. I tried these, it worked when I ran the commands on terminal.

But when I stored the echo in log file and vi log file, it shows something different.

e.g
$echo "\033[1m this a bold message\033[0m" > log
$ cat log
this a bold message
$ more log
this a bold message
$vi log
"log" 1 line, 29 characters
^[[1m this a bold message^[[0m
~
Similarly I downloaded the log file and opened in Microsoft word, it shows the result same as vi.

Do you know any commands or echo options which will store the character in file with special formatting which we specify with echo options.

Thanks,
Satish
# 4  
Old 09-21-2006
yes we have tput command see man page for tput.I don't know how you will
see bold characters in vi.because vi is not designed to be like that.

Last edited by Dhruva; 09-21-2006 at 08:00 AM..
# 5  
Old 09-21-2006
Computer weird solution

You can rename the log file with .c extension and then whleprinting the error messages print them within " " or within /* */
[code]
echo "\"ERROR MESSG\"" > log.c
echo "/*ANOTHER ERROR*/" >> log.c
[code]

now when i do vi log.c you will see
[color=red]"ERROR MESSG"[color]
[color=blue]/*ANOTHER ERROR*/[color]

maybe this kinda result is not expected, but thats the best i could think of :P

hope this helps Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send mail with font color change

Hi All, I have a file that contains following entries. I want to highlight the line that has word as "FAILURE" while sending the email. File ------------------------------------------------------------ Job Name: ABC Start Time: 07/20/2019 07:32:39 End Time: 07/20/2019... (4 Replies)
Discussion started by: sdosanjh
4 Replies

2. Shell Programming and Scripting

Help with changing font size in konsole

I created a very very basic script that opens multiple konsole terminals when I run the script which essentially sshs into a jump box into the end device and tails some logs etc etc. A few of the konsoles run scripts where the default font size is too big and the lines are cut off. Which I would... (3 Replies)
Discussion started by: NiCe
3 Replies

3. UNIX for Advanced & Expert Users

How to set font color for STDIN,STDOUT and STDERR?

I want to differentiate the STDOUT and STDERR messages in my terminal . If a script or command is printing a message in terminal I want to differentiate by colors, Is it possible ? Example: $date Wed Jul 27 12:36:50 IST 2011 $datee bash: datee: command not found $alias ls alias... (2 Replies)
Discussion started by: ungalnanban
2 Replies

4. Shell Programming and Scripting

font color in script

i am using ubuntu 11.04 and i just finished writing a shell script but i was wanting to know if their is a way to change the font color of just one sentence? (2 Replies)
Discussion started by: hotshot247
2 Replies

5. Shell Programming and Scripting

Change color or font when executing a script

I'm writing a simple menu script and I would like to output the whole script using background color: black AND foreground color:white. Meaning if the ssh terminal of a user is set to green for example, it will change to my desired color when menu script is executed. Once the script is exited, it... (1 Reply)
Discussion started by: lhareigh890
1 Replies

6. Programming

changing text color in c

I'm writing my own Unix ls command in c and I was wondering if anyone knows how to or can point me to a tutorial that shows me how to change the text color of the filename depending on if it's a directory, regular file, linked file, etc..., like the real ls command does? Thanks. (4 Replies)
Discussion started by: snag49ers
4 Replies

7. Shell Programming and Scripting

Specifying font type and color in a shell script

Hi, I am new to shell script. Can you please tell me, whether can we specify font type and color in a shell script? If so, how to do this? Thanks in advance. (4 Replies)
Discussion started by: Vani_Govind
4 Replies

8. UNIX for Dummies Questions & Answers

How to change the font or color of text

Hi Gurus, I have a small requirement where i want to change the color & font of some text in a file. i have a file error.txt which will be created in the script using egrep. After that iam adding these lines at head & tail to that file using the following code awk 'BEGIN{print"Please... (4 Replies)
Discussion started by: pssandeep
4 Replies

9. Shell Programming and Scripting

Font Color Change Using .profile

Does anyone know how can I change font color, background color etc for a particular user using .profile? Any help is appreciated. (0 Replies)
Discussion started by: fifo_vs_lifo23
0 Replies

10. UNIX for Advanced & Expert Users

Changing font in script

I'm trying to figure out how to change the font or color of output in the middle of a shell script. I can't find anything that tells me how to do that. Any ideas? (1 Reply)
Discussion started by: MDyer18
1 Replies
Login or Register to Ask a Question