how to change color a text in HTML table through shell script

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











up vote
-1
down vote

favorite












Can anyone please help me with this. I have a CSV file which contains like below text. I could create an HTML file from the CSV file however unable to change the text color like for success it should be green and for all failures, it should be red.



CSV file contents




HB load,14-Jun-2018, success 
MF load,14-Jun-2018,failure
SP load,14-Jun-2018,success
LN load,14-Jun-2018,failure


Script




awk 'BEGIN
FS=","
print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"


printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"

END
print "</TABLE></BODY></HTML>"

' test > file.html
(
echo "To: xyz@abc.com"
echo "Subject: Report"
echo "Content-Type: text/html"
echo
cat file.html
echo
) | /usr/sbin/sendmail -t


file.html contents




<HTML><TABLE border=1><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>
<TR><TD>HB load</TD><TD>14-Jun-2018</TD><TD>success </TD></TR>
<TR><TD>MF load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
<TR><TD>SP load</TD><TD>14-Jun-2018</TD><TD>success</TD></TR>
<TR><TD>LN load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
</TABLE></BODY></HTML>






share|improve this question

























    up vote
    -1
    down vote

    favorite












    Can anyone please help me with this. I have a CSV file which contains like below text. I could create an HTML file from the CSV file however unable to change the text color like for success it should be green and for all failures, it should be red.



    CSV file contents




    HB load,14-Jun-2018, success 
    MF load,14-Jun-2018,failure
    SP load,14-Jun-2018,success
    LN load,14-Jun-2018,failure


    Script




    awk 'BEGIN
    FS=","
    print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"


    printf "<TR>"
    for(i=1;i<=NF;i++)
    printf "<TD>%s</TD>", $i
    print "</TR>"

    END
    print "</TABLE></BODY></HTML>"

    ' test > file.html
    (
    echo "To: xyz@abc.com"
    echo "Subject: Report"
    echo "Content-Type: text/html"
    echo
    cat file.html
    echo
    ) | /usr/sbin/sendmail -t


    file.html contents




    <HTML><TABLE border=1><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>
    <TR><TD>HB load</TD><TD>14-Jun-2018</TD><TD>success </TD></TR>
    <TR><TD>MF load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
    <TR><TD>SP load</TD><TD>14-Jun-2018</TD><TD>success</TD></TR>
    <TR><TD>LN load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
    </TABLE></BODY></HTML>






    share|improve this question























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      Can anyone please help me with this. I have a CSV file which contains like below text. I could create an HTML file from the CSV file however unable to change the text color like for success it should be green and for all failures, it should be red.



      CSV file contents




      HB load,14-Jun-2018, success 
      MF load,14-Jun-2018,failure
      SP load,14-Jun-2018,success
      LN load,14-Jun-2018,failure


      Script




      awk 'BEGIN
      FS=","
      print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"


      printf "<TR>"
      for(i=1;i<=NF;i++)
      printf "<TD>%s</TD>", $i
      print "</TR>"

      END
      print "</TABLE></BODY></HTML>"

      ' test > file.html
      (
      echo "To: xyz@abc.com"
      echo "Subject: Report"
      echo "Content-Type: text/html"
      echo
      cat file.html
      echo
      ) | /usr/sbin/sendmail -t


      file.html contents




      <HTML><TABLE border=1><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>
      <TR><TD>HB load</TD><TD>14-Jun-2018</TD><TD>success </TD></TR>
      <TR><TD>MF load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
      <TR><TD>SP load</TD><TD>14-Jun-2018</TD><TD>success</TD></TR>
      <TR><TD>LN load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
      </TABLE></BODY></HTML>






      share|improve this question













      Can anyone please help me with this. I have a CSV file which contains like below text. I could create an HTML file from the CSV file however unable to change the text color like for success it should be green and for all failures, it should be red.



      CSV file contents




      HB load,14-Jun-2018, success 
      MF load,14-Jun-2018,failure
      SP load,14-Jun-2018,success
      LN load,14-Jun-2018,failure


      Script




      awk 'BEGIN
      FS=","
      print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"


      printf "<TR>"
      for(i=1;i<=NF;i++)
      printf "<TD>%s</TD>", $i
      print "</TR>"

      END
      print "</TABLE></BODY></HTML>"

      ' test > file.html
      (
      echo "To: xyz@abc.com"
      echo "Subject: Report"
      echo "Content-Type: text/html"
      echo
      cat file.html
      echo
      ) | /usr/sbin/sendmail -t


      file.html contents




      <HTML><TABLE border=1><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>
      <TR><TD>HB load</TD><TD>14-Jun-2018</TD><TD>success </TD></TR>
      <TR><TD>MF load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
      <TR><TD>SP load</TD><TD>14-Jun-2018</TD><TD>success</TD></TR>
      <TR><TD>LN load</TD><TD>14-Jun-2018</TD><TD>failure</TD></TR>
      </TABLE></BODY></HTML>








      share|improve this question












      share|improve this question




      share|improve this question








      edited Jun 26 at 6:54









      SivaPrasath

      3,88611737




      3,88611737









      asked Jun 26 at 5:29









      John

      23




      23




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Try this,



          awk 'BEGIN
          FS=","
          print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"


          printf "<TR>"
          for(i=1;i<=NF;i++)
          printf "<TD>%s</TD>", $i
          print "</TR>"

          END
          print "</TABLE></BODY></HTML>"

          ' test > file.html
          sed -i "s/failure/<font color="red">failure</font>/g;s/success/<font color="green">success</font>/g" file.html
          (
          echo "To: xyz@abc.com"
          echo "Subject: Report"
          echo "Content-Type: text/html"
          echo
          cat file.html
          echo
          ) | /usr/sbin/sendmail -t





          share|improve this answer

















          • 1




            Thanks SivaPrasath for all your help. It's working fine for me. :)
            – John
            Jun 26 at 9:13










          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%2f451911%2fhow-to-change-color-a-text-in-html-table-through-shell-script%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,



          awk 'BEGIN
          FS=","
          print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"


          printf "<TR>"
          for(i=1;i<=NF;i++)
          printf "<TD>%s</TD>", $i
          print "</TR>"

          END
          print "</TABLE></BODY></HTML>"

          ' test > file.html
          sed -i "s/failure/<font color="red">failure</font>/g;s/success/<font color="green">success</font>/g" file.html
          (
          echo "To: xyz@abc.com"
          echo "Subject: Report"
          echo "Content-Type: text/html"
          echo
          cat file.html
          echo
          ) | /usr/sbin/sendmail -t





          share|improve this answer

















          • 1




            Thanks SivaPrasath for all your help. It's working fine for me. :)
            – John
            Jun 26 at 9:13














          up vote
          1
          down vote













          Try this,



          awk 'BEGIN
          FS=","
          print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"


          printf "<TR>"
          for(i=1;i<=NF;i++)
          printf "<TD>%s</TD>", $i
          print "</TR>"

          END
          print "</TABLE></BODY></HTML>"

          ' test > file.html
          sed -i "s/failure/<font color="red">failure</font>/g;s/success/<font color="green">success</font>/g" file.html
          (
          echo "To: xyz@abc.com"
          echo "Subject: Report"
          echo "Content-Type: text/html"
          echo
          cat file.html
          echo
          ) | /usr/sbin/sendmail -t





          share|improve this answer

















          • 1




            Thanks SivaPrasath for all your help. It's working fine for me. :)
            – John
            Jun 26 at 9:13












          up vote
          1
          down vote










          up vote
          1
          down vote









          Try this,



          awk 'BEGIN
          FS=","
          print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"


          printf "<TR>"
          for(i=1;i<=NF;i++)
          printf "<TD>%s</TD>", $i
          print "</TR>"

          END
          print "</TABLE></BODY></HTML>"

          ' test > file.html
          sed -i "s/failure/<font color="red">failure</font>/g;s/success/<font color="green">success</font>/g" file.html
          (
          echo "To: xyz@abc.com"
          echo "Subject: Report"
          echo "Content-Type: text/html"
          echo
          cat file.html
          echo
          ) | /usr/sbin/sendmail -t





          share|improve this answer













          Try this,



          awk 'BEGIN
          FS=","
          print "<HTML>""<TABLE border="1"><TH>JOB_NAME</TH><TH>RUN_DATE</TH><TH>STATUS</TH>"


          printf "<TR>"
          for(i=1;i<=NF;i++)
          printf "<TD>%s</TD>", $i
          print "</TR>"

          END
          print "</TABLE></BODY></HTML>"

          ' test > file.html
          sed -i "s/failure/<font color="red">failure</font>/g;s/success/<font color="green">success</font>/g" file.html
          (
          echo "To: xyz@abc.com"
          echo "Subject: Report"
          echo "Content-Type: text/html"
          echo
          cat file.html
          echo
          ) | /usr/sbin/sendmail -t






          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered Jun 26 at 6:20









          SivaPrasath

          3,88611737




          3,88611737







          • 1




            Thanks SivaPrasath for all your help. It's working fine for me. :)
            – John
            Jun 26 at 9:13












          • 1




            Thanks SivaPrasath for all your help. It's working fine for me. :)
            – John
            Jun 26 at 9:13







          1




          1




          Thanks SivaPrasath for all your help. It's working fine for me. :)
          – John
          Jun 26 at 9:13




          Thanks SivaPrasath for all your help. It's working fine for me. :)
          – John
          Jun 26 at 9:13












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451911%2fhow-to-change-color-a-text-in-html-table-through-shell-script%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