awk find string and do i blue color


 
Thread Tools Search this Thread
Top Forums Programming awk find string and do i blue color
# 1  
Old 05-18-2012
awk find string and do i blue color

Hi!

i have one file.txt that i send by email.
i want to write a script that searches inside this file for a special string and makes it blue color.

Thank u very much!

Ervin
# 2  
Old 05-18-2012
Are you using sendmail ?

Are you sending in html format ?

Post your command and the sample contents and desired output
# 3  
Old 05-18-2012
Quote:
Originally Posted by itkamaraj
Are you using sendmail ?

Are you sending in html format ?

Post your command and the sample contents and desired output
It's just a text file in linux. Yes, i send it by email. But i want to put some colors into it when it arrives in my email. With shell i know i cannt do it.

The file looks like this:

"Find below report for last three mons:

January- IP logs report
etc etc etc etc
February - IP logs report
etc etc etc etc..."

i want that the subjects like "January - IP logs report" to be blue, in order to distinguish, because the report is really long.

Thank u in advance!!!
# 4  
Old 05-18-2012
your file should be like this..
Code:
<html>
<body>
<font color=blue><b>January- IP logs report</b></font>
etc etc etc etc
<font color=blue><b>February - IP logs report</b></font>
etc etc etc etc...
</body>
<html>

And you need to use sendmail
Code:
(
echo "From: abc@xyz.com "
echo "To: abc@xyz.com "
echo "MIME-Version: 1.0"
echo "Content-Type: multipart/alternative; " 
echo "Subject: Test HTML e-mail." 
cat filename
) | sendmail -t

# 5  
Old 05-18-2012
thank u for replying,

but i want that the html tags to be set automatically by one script.
would you please give my any ideas?

Thank u very much!!
# 6  
Old 05-18-2012
Code:
$ awk 'BEGIN{print "<html><body>"}/report/{$0="<font color=blue>"$0"</font>"}END{print "</body></html>"}1' file.txt

the above code will put the font color, where ever it find the word report.
# 7  
Old 05-18-2012
Thank u for your help,

Yes, it does make blue that strings, but it totally destroys my coloumns, rows...
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk find which column contains string

i want to search columns in a variable and any column contains a particular string, i want to print the value of that column $ echo "${USEDMEMORY}" memTotalReal=3925908 memAvailReal=1109812 memBuffer=242676 memCached=641628 $ $ echo "${USEDMEMORY}" | awk '/memAvailReal/' so what im trying... (6 Replies)
Discussion started by: SkySmart
6 Replies

2. Shell Programming and Scripting

awk find and print next string

Can I do this in one awk session. Solution I have is poor. I want to return the number after PID. echo "Start: 12345 is used by PID:11111 username" | awk -F: '{print $3}' | awk '{print $1}' (6 Replies)
Discussion started by: u20sr
6 Replies

3. Shell Programming and Scripting

awk - find number in string

I am trying to go through a file that has a few million lines. I want to only pull lines that contain a number anywhere in the ninth field, but it has to be after a "/" character. Here is my awk: awk -F\| '$9 ~ /\/*{1,}*/ {print $0}' file1 > file2 However, it is just printing out every... (3 Replies)
Discussion started by: dagamier
3 Replies

4. Shell Programming and Scripting

Awk - find string, search lines below string for other strings

What's the easiest way to search a file for a specific string and then look for other instances after that? I want to search for all Virtual Hosts and print out the Server Name and Document Root (if it has that info), while discarding the rest of the info. Basically my file looks like this: ...... (6 Replies)
Discussion started by: Mbohmer
6 Replies

5. Shell Programming and Scripting

awk - find first instance of string after NR==10

How do I use awk to find the NR of first instance of a specific string after eg NR==10? I need to find the first instance of the word "class" after a specific NR. (2 Replies)
Discussion started by: locoroco
2 Replies

6. UNIX for Dummies Questions & Answers

AWK...find a string ,if so print it

Hi, I need to find a string, if it finds then I need to print it , otherwise it has to goto next line.... input is====> uid = shashi, india uid ,uid= asia uid= none, uid=india. none ========== output shold be uid = shashi, india uid , uid= asia uid= none, uid=india. none ... (1 Reply)
Discussion started by: hegdeshashi
1 Replies
Login or Register to Ask a Question