dears iI have the folowing file which is called test.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="generator" content="SQL*Plus 12.2.0">
<style type='text/css'> body {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} p {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} table,tr,td {font:10pt Arial,Helvetica,sans-serif; color:Black; background:#f7f7e7; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;} th {font:bold 10pt Arial,Helvetica,sans-serif; color:#336699; background:#cccc99; padding:0px 0px 0px 0px;} h1 {font:16pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; border-bottom:1px solid #cccc99; margin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px;-
} h2 {font:bold 10pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; margin-top:4pt; margin-bottom:0pt;} a {font:9pt Arial,Helvetica,sans-serif; color:#663300; background:#ffffff; margin-top:0pt; margin-bottom:0pt; vertical-align:top;}</style><title>SQL*Plus Report</title>
</head>
<body>
<p>
<table border='1' width='90%' align='center' summary='Script output'>
<tr>
<th scope="col">
NAME
</th>
<th scope="col">
FREE_PERCENT
</th>
</tr>
<tr>
<td>
DG_BACKUP
</td>
<td>
50%
</td>
</tr>
<tr>
<td>
DG_DATA
</td>
<td>
96%
</td>
</tr>
<tr>
<td>
DG_INDEX
</td>
<td>
80%
</td>
</tr>
<tr>
<td>
DG_ORA
</td>
<td>
19%
</td>
</tr>
</table>
<p>
<br>
</body>
</html>
iI want to find the values that are less than 20% and set the background forto red:
<td bgcolor="red">
using sed or any other tool. So, for example,
<td>
80%
</td>
would remain unchanged, but
<td>
19%
</td>
wound be changed to
<td bgcolor="red">
19%
</td>
Script I have tried so far.
number_of_lines_test=(`grep -n % test.html |sed -e '1d' |awk -F"[:%]" '{if ($2 <= 50) print $1}'`)
for i in `seq 0 $((${#number_of_lines_test[@]} - 1))`
do
sed -i -e "$((${number_of_lines_test[i]} - 1))s/<td>/<td bgcolor=\"red\">/" test.html
done