Sponsored Content
Top Forums Shell Programming and Scripting Identify Color and send email with same color Post 302894036 by SriniShoo on Sunday 23rd of March 2014 08:18:21 AM
Old 03-23-2014
You can add other conditions and use below
Code:
ls -l | awk '{if($1 ~ /^d/) {$9 = ("<FONT COLOR=\"GREEN\">" $9 "</FONT>")}
  else if($1 ~ /^l/) {$9 = ("<FONT COLOR=\"BLUE\">" $9 "</FONT>")}
  else if($1 ~ /x/) {$9 = ("<FONT COLOR=\"PURPLE\">" $9 "</FONT>")}
  else if($9 ~ /.gz$/ || $9 ~ /.Z$/) {$9 = ("<FONT COLOR=\"RED\">" $9 "</FONT>")}
  else {$9 = ("<FONT COLOR=\"WHITE\">" $9 "</FONT>")}; print}'

or use below and save the output to sample.html and open the html file to see colors

Code:
ls -l | awk '{if($1 ~ /^d/) {$9 = ("<FONT COLOR=\"BLUE\">" $9 "</FONT>")}
  else if($1 ~ /^l/) {$9 = ("<FONT COLOR=\"PURPLE\">" $9 "</FONT>")}
  else if($1 ~ /x/) {$9 = ("<FONT COLOR=\"GREEN\">" $9 "</FONT>")}
  else if($9 ~ /.gz$/ || $9 ~ /.Z$/) {$9 = ("<FONT COLOR=\"RED\">" $9 "</FONT>")}
  else {$9 = ("<FONT COLOR=\"BLACK\">" $9 "</FONT>")}; print $0 "<BR>"}' > sample.html


Last edited by SriniShoo; 03-23-2014 at 09:48 AM.. Reason: changed color from white to black and added "<BR>" tag for html
 

2 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to change the background color in the init 3 mode(not line color)

Hello, I am using RHEL 6.1 on VMware I am searching for a way to change background color (not line by line color wich one can using tput command) basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)
Discussion started by: Dexobox
2 Replies

2. 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
WWW::Topica::Mail(3pm)					User Contributed Perl Documentation				    WWW::Topica::Mail(3pm)

NAME
WWW::Topica::Mail - parse a single Topica mailing list mail SYNOPSIS
my $index = WWW::Topic::Index->new($index_html); foreach my $mess_id ($index->message_ids) { # the mail has some information and also provides a link to the reply ... my $mail = WWW::Topica::Mail->new($topica->fetch_mail($mess_id), $mess_id); # which has other information (like the un-htmled mail and the email address) ... my $reply = WWW::Topica::Reply->new($topica->fetch_reply($mail->id, $mail->eto), $mail->id, $mail->eto); } print "Next offset is ".$index->next." "; print "Previous offset is ".$index->prev." "; DESCRIPTION
Used to parse a single message page from Topica.com's mailing list indexes. Message pages have the subject and the date and time of the mail being sent as well as a full name of each sender. METHODS
new <page html> <id> Takes the page html and the message-id and parses the html. parse <html> Parse the html to get message ids and next & prev offsets. id Get the id of this mail eto Get the eto of the next reply we need to get date Get the date of this mail subject The subject of the mail from Get the name of the person it was from body Get the body of the mail. AUTHOR
Simon Wistow <simon@thegestalt.org> COPYRIGHT
Copyright (c) 2004, Simon Wistow perl v5.10.1 2006-01-03 WWW::Topica::Mail(3pm)
All times are GMT -4. The time now is 04:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy