change the background color if a number is less than a spacific number (html format)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












dears i 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>


i want to find the values that are less than 20% and set the background for red:



<td bgcolor="red">


using sed or any other tool



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






share|improve this question





















  • welcome to U&L, we are not a free scrpting service, what have you tried so far ?
    – Archemar
    Jun 25 at 11:10










  • actually i am new to scripting and i have thought of using sed the problem is after looping over the lines and check the value after using awk to cut the % sympol but how can i edit line before the matching reasults
    – ammar
    Jun 25 at 11:23














up vote
0
down vote

favorite












dears i 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>


i want to find the values that are less than 20% and set the background for red:



<td bgcolor="red">


using sed or any other tool



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






share|improve this question





















  • welcome to U&L, we are not a free scrpting service, what have you tried so far ?
    – Archemar
    Jun 25 at 11:10










  • actually i am new to scripting and i have thought of using sed the problem is after looping over the lines and check the value after using awk to cut the % sympol but how can i edit line before the matching reasults
    – ammar
    Jun 25 at 11:23












up vote
0
down vote

favorite









up vote
0
down vote

favorite











dears i 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>


i want to find the values that are less than 20% and set the background for red:



<td bgcolor="red">


using sed or any other tool



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






share|improve this question













dears i 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>


i want to find the values that are less than 20% and set the background for red:



<td bgcolor="red">


using sed or any other tool



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








share|improve this question












share|improve this question




share|improve this question








edited Jul 2 at 8:53









SivaPrasath

3,88611737




3,88611737









asked Jun 25 at 11:05









ammar

145




145











  • welcome to U&L, we are not a free scrpting service, what have you tried so far ?
    – Archemar
    Jun 25 at 11:10










  • actually i am new to scripting and i have thought of using sed the problem is after looping over the lines and check the value after using awk to cut the % sympol but how can i edit line before the matching reasults
    – ammar
    Jun 25 at 11:23
















  • welcome to U&L, we are not a free scrpting service, what have you tried so far ?
    – Archemar
    Jun 25 at 11:10










  • actually i am new to scripting and i have thought of using sed the problem is after looping over the lines and check the value after using awk to cut the % sympol but how can i edit line before the matching reasults
    – ammar
    Jun 25 at 11:23















welcome to U&L, we are not a free scrpting service, what have you tried so far ?
– Archemar
Jun 25 at 11:10




welcome to U&L, we are not a free scrpting service, what have you tried so far ?
– Archemar
Jun 25 at 11:10












actually i am new to scripting and i have thought of using sed the problem is after looping over the lines and check the value after using awk to cut the % sympol but how can i edit line before the matching reasults
– ammar
Jun 25 at 11:23




actually i am new to scripting and i have thought of using sed the problem is after looping over the lines and check the value after using awk to cut the % sympol but how can i edit line before the matching reasults
– ammar
Jun 25 at 11:23










1 Answer
1






active

oldest

votes

















up vote
1
down vote













Try this,



number=(`grep -n "^[0-1][0-9]" test.html | awk -F ':' 'a=$1-1;print a'`)
for i in $number[@]
do
sed -i "$i s/.*/<td bgcolor="red">/" test.html
done





share|improve this answer





















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451737%2fchange-the-background-color-if-a-number-is-less-than-a-spacific-number-html-for%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Try this,



    number=(`grep -n "^[0-1][0-9]" test.html | awk -F ':' 'a=$1-1;print a'`)
    for i in $number[@]
    do
    sed -i "$i s/.*/<td bgcolor="red">/" test.html
    done





    share|improve this answer

























      up vote
      1
      down vote













      Try this,



      number=(`grep -n "^[0-1][0-9]" test.html | awk -F ':' 'a=$1-1;print a'`)
      for i in $number[@]
      do
      sed -i "$i s/.*/<td bgcolor="red">/" test.html
      done





      share|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        Try this,



        number=(`grep -n "^[0-1][0-9]" test.html | awk -F ':' 'a=$1-1;print a'`)
        for i in $number[@]
        do
        sed -i "$i s/.*/<td bgcolor="red">/" test.html
        done





        share|improve this answer













        Try this,



        number=(`grep -n "^[0-1][0-9]" test.html | awk -F ':' 'a=$1-1;print a'`)
        for i in $number[@]
        do
        sed -i "$i s/.*/<td bgcolor="red">/" test.html
        done






        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jun 25 at 18:43









        SivaPrasath

        3,88611737




        3,88611737






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451737%2fchange-the-background-color-if-a-number-is-less-than-a-spacific-number-html-for%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay