Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk HTML Conditional Formating Post 303017801 by Don Cragun on Tuesday 22nd of May 2018 09:50:04 PM
Old 05-22-2018
Digging just slightly deeper, note that assuming that values in your fields range from 0 through 100, the first if statement test:
Code:
 if ($i <=75 && $i <=100 )

will be satisfied only by values less than or equal to 75 (which does not seem to meet your conditions for displaying values in red. If I guessed correctly at the output you're getting, you might want to try replacing:
Code:
                        if ($i <=75 && $i <=100 )
                                   print "<td> <b><FONT COLOR=RED FACE="verdana"SIZE=9 ></b>"  $i  "</td>"


                        else

                        if ($i <=40 && $i <=74 )

                                   print "<td> <b><FONT COLOR=Yellow FACE="verdana"SIZE=9 ></b>"  $i  "</td>"

                        else
                                   print "<td> <FONT COLOR=GREEN  FACE="verdana"SIZE=9 >" $i "</td>"

with:
Code:
                        if (($i + 0) >= 75)
                                   print "<td> <b><FONT COLOR=RED FACE="verdana"SIZE=9 ></b>"  $i  "</td>"
                        else if (($i + 0) >= 40)
                                   print "<td> <b><FONT COLOR=Yellow FACE="verdana"SIZE=9 ></b>"  $i  "</td>"
                        else
                                   print "<td> <FONT COLOR=GREEN  FACE="verdana"SIZE=9 >" $i "</td>"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK - conditional cause

Hello guys, I want to make a conditional cause in the following file using awk: awk '{ if ($2 != 0) print $1, $2, $3}' test.csv > test2.csv FILE EXAMPLE = test.csv string,number,date abc,0,20050101 def,1,20060101 ghi,2,20040101 jkl,12,20090101 mno,123,20020101 ... (2 Replies)
Discussion started by: Rafael.Buria
2 Replies

2. Shell Programming and Scripting

Awk Conditional

Hi Guys, i have this files: xyz20080716.log opqrs20080716.log abcdef20080716.log xyz20080717.log oprs20080717.log abcde20080717.log currentdate: 20080717.log I want to make script to zip the file for past day. Can anyone help for this? i've just learn awk scripting & still confused with... (3 Replies)
Discussion started by: icy_blu_blu
3 Replies

3. Shell Programming and Scripting

AWK: formating number without printf

Hello, I wrote a script that does lot of things, and I would like to change the format of a number but without printing it now (so I don't want to use printf as it will print the value immediately). Schematically here is what I have: awk 'BEGIN{number=0.01234567} $1==$2{$3=number}... (5 Replies)
Discussion started by: jolecanard
5 Replies

4. Shell Programming and Scripting

formating sql file using awk or sed

Hi, I have a file where I would like to add a prompt type object_name statement before every create commnad create or replace force view test_view_01 ( col1 col2 col3 ) as (select a,b,c from sometable ); create or replace view test_view_02 ( col4 col5 col6 ) as (5 Replies)
Discussion started by: jville
5 Replies

5. Shell Programming and Scripting

conditional statement in awk

Hi all, I have a file containing the values that would be use as the basis for printing the lines of another set of files using awk. What I want to do is something like the one below: stdev.txt 0.21 0.42 0.32 0.25 0.15 file1.txt file2.txt file3.txt ..filen.txt 0.45 0.23 ... (4 Replies)
Discussion started by: ida1215
4 Replies

6. Shell Programming and Scripting

Formating output in html

Hi Guys, I was searching and landed up something here only. This is the code and I want the formatted html in email but that is not working, anybody knows the reason why? #!/bin/sh set -x DATE=`date -u` # Print beginning of webpage function html_header { cat <<END ... (5 Replies)
Discussion started by: bluemind2005
5 Replies

7. Shell Programming and Scripting

HTML mail formating in UNIX

Hi i need to send mail from my Unix server i used the below code. From: TTS.OO.Monitoring.Operations Subject: Error X-Mailer: htmlmail 1.0 Mime-Version: 1.0 Content-Type: text/html; charset=US-ASCII <HTML><head><style type='text/css'> table.altrowstable { font-family:... (6 Replies)
Discussion started by: mohanalakshmi
6 Replies

8. Shell Programming and Scripting

Conditional awk

Hello All, I have a file like this: bash-3.00$ cat 1.txt 201112091147|0|1359331220|1025 201112091147|0|1359331088|1024 201112091144|0|1359331172|1025 201112091147|0|1359331220|1021 201112091149|0|1359331088|1027 201112091144|0|1359331172|1029 and a list of MSISDNs in another file... (9 Replies)
Discussion started by: EAGL€
9 Replies

9. Shell Programming and Scripting

awk and HTML with conditional text colour

Hello All, I am using awk with html options to format and send output to another file. Below command works fine, no issues. awk 'BEGIN{print "<table border="1" width="1000" >"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END {print "</table>"}' ${TMPLOGFILE1} >>... (0 Replies)
Discussion started by: jvmani_1
0 Replies

10. Shell Programming and Scripting

Help with ... Formating the file using awk

I have a file like below position1 0 7802 7802 0 client1 - - position1 8 8032 8032 0 client1 ... (7 Replies)
Discussion started by: manas_ranjan
7 Replies
Test::Image::GD(3pm)					User Contributed Perl Documentation				      Test::Image::GD(3pm)

NAME
Test::Image::GD - A module for testing images using GD SYNOPSIS
use Test::More plan => 1; use Test::Image::GD; cmp_image('test.gif', 'control.gif', '... these images should match'); # or my $test = GD::Image->new('test.gif'); my $control = GD::Image->new('control.gif'); cmp_image($test, $control, '... these images should match'); # some other test functions ... size_ok('camel.gif', [ 100, 350 ], '... the image is 100 x 350"); height_ok('test.gif', 200, '... the image has a height of 200'); width_ok('test.gif', 200, '... the image has a width of 200'); DESCRIPTION
This module is meant to be used for testing custom graphics, it attempts to "visually" compare the images, this means it ignores invisible differences like color palettes and metadata. It also provides some extra functions to check the size of the image. FUNCTIONS
cmp_image ($got, $expected, $message) This function will tell you whether the two images will look different, ignoring differences in the order of colors in the color palette and other invisible changes. Both $got and $expected can be either instances of "GD::Image" or either a file handle or a file path (both are valid parameters to the "GD::Image" constructor). size_ok ($got, [ $width, $height ], ?$message) This function will check if an image is a certain size. As with the "cmp_image" function, the $got parameter can be either an instance of "GD::Image" or a file handle or a file path (all are valid parameters to the "GD::Image" constructor). height_ok ($got, $height, ?$message) This function will check if an image is a certain height. As with the "cmp_image" function, the $got parameter can be either an instance of "GD::Image" or a file handle or a file path (all are valid parameters to the "GD::Image" constructor). width_ok ($got, $width, ?$message) This function will check if an image is a certain width. As with the "cmp_image" function, the $got parameter can be either an instance of "GD::Image" or a file handle or a file path (all are valid parameters to the "GD::Image" constructor). TO DO
Add more functions This module currently serves a very basic need of mine, however, I am sure as I start writing more tests against images I will find a need for other testing functions. Any suggestions are welcome. BUGS
None that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it. CODE COVERAGE
I use Devel::Cover to test the code coverage of my tests, below is the Devel::Cover report on this module test suite. ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ Test/Image/GD.pm 100.0 91.7 63.6 100.0 100.0 100.0 93.7 ---------------------------- ------ ------ ------ ------ ------ ------ ------ Total 100.0 91.7 63.6 100.0 100.0 100.0 93.7 ---------------------------- ------ ------ ------ ------ ------ ------ ------ SEE ALSO
The "compare" function of "GD::Image" class, that is how this "cmp_image" is implemented. AUTHOR
Stevan Little, <stevan@iinteractive.com> COPYRIGHT AND LICENSE
Copyright 2005 by Infinity Interactive, Inc. <http://www.iinteractive.com> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2005-12-09 Test::Image::GD(3pm)
All times are GMT -4. The time now is 05:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy