Displaying the cell in different color
by nextStep from LinuxQuestions.org on (#599QY)
Hi Team,
My requirement is to display the value of html cell in red color based on the value in another cell .
Example:The value in the column "Actual count" should be displayed in red color as it is greater than value in "threshold" column.
The content of testresult.txt are as follows
Properties 20201020 281899 32000 Warning
Code:fn_presentationLogic()
{
awk 'BEGIN{
FS=" "
print "<HTML>""<TABLE border="1"><TH>Item</TH><TH>Date</TH><TH>Actual count</TH><TH>Threshold</TH><TH>Status</TH> "
}
{
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
}
END{
print "</TABLE></BODY></HTML>"
}
' testresult.txt > HotelDashboard.html
sed -i "s/Warning/<font color="red">$3<\/font>/g;s/Normal/<font color="green">$3<\/font>/g" HotelDashboard.html
}
fn_presentationLogicI have used the above sed command to substitute the third cell if it finds "Warning" but in vain. Could you please advise.


My requirement is to display the value of html cell in red color based on the value in another cell .
Example:The value in the column "Actual count" should be displayed in red color as it is greater than value in "threshold" column.
The content of testresult.txt are as follows
Properties 20201020 281899 32000 Warning
Code:fn_presentationLogic()
{
awk 'BEGIN{
FS=" "
print "<HTML>""<TABLE border="1"><TH>Item</TH><TH>Date</TH><TH>Actual count</TH><TH>Threshold</TH><TH>Status</TH> "
}
{
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
}
END{
print "</TABLE></BODY></HTML>"
}
' testresult.txt > HotelDashboard.html
sed -i "s/Warning/<font color="red">$3<\/font>/g;s/Normal/<font color="green">$3<\/font>/g" HotelDashboard.html
}
fn_presentationLogicI have used the above sed command to substitute the third cell if it finds "Warning" but in vain. Could you please advise.