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
Imager::Color::Float(3pm)				User Contributed Perl Documentation				 Imager::Color::Float(3pm)

NAME
Imager::Color::Float - Rough floating point sample color handling SYNOPSIS
$color = Imager::Color->new($red, $green, $blue); $color = Imager::Color->new($red, $green, $blue, $alpha); $color = Imager::Color->new("#C0C0FF"); # html color specification $color->set($red, $green, $blue); $color->set($red, $green, $blue, $alpha); $color->set("#C0C0FF"); # html color specification ($red, $green, $blue, $alpha) = $color->rgba(); @hsv = $color->hsv(); # not implemented but proposed $color->info(); DESCRIPTION
This module handles creating color objects used by Imager. The idea is that in the future this module will be able to handle color space calculations as well. A floating point Imager color consists of up to four components, each in the range 0.0 to 1.0. Unfortunately the meaning of the components can change depending on the type of image you're dealing with: o for 3 or 4 channel images the color components are red, green, blue, alpha. o for 1 or 2 channel images the color components are gray, alpha, with the other two components ignored. An alpha value of zero is fully transparent, an alpha value of 1.0 is fully opaque. METHODS
new This creates a color object to pass to functions that need a color argument. set This changes an already defined color. Note that this does not affect any places where the color has been used previously. rgba() This returns the red, green, blue and alpha channels of the color the object contains. info Calling info merely dumps the relevant color to the log. AUTHOR
Arnar M. Hrafnkelsson, addi@umich.edu And a great deal of help from others - see the "README" for a complete list. SEE ALSO
Imager(3), Imager::Color. http://imager.perl.org/ perl v5.14.2 2011-06-06 Imager::Color::Float(3pm)
All times are GMT -4. The time now is 06:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy