Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

formatting html table using awk

N_RajOct 25 2017 — edited Oct 25 2017

Hi All,

We have Redhat 6.5 server. I am preparing a shell script to get a html output.

The text file contains 7 lines with  heading.

File Name : Memory.txt

Memory-Type Size-GB

Total-Memory    55GB

Used-Memory   50GB

Free-Memory     5GB

etc.....

I am preparing a script to get a html output based on the about data ( Memory.txt )

The below Command use to generate a html file

awk'

BEGIN{

     print "<html> \n <body> \n <tabel cellpadding="10" border="1">

     Print "<h5> Memory Details </h5>

     }

     {

     print "<tr>"

     for(i=1;i<=NF;i++)

     print "<td>" $i "</td>"

     print "</tr>"

     }

End{

print "\n</table> /n<body> /n <html>"

} Memory.txt > test.html

With the help of the above command,i can get the html output.But unable to change the column header font size and its color.

I tried the below using multiple for loop but no luck.

awk'

BEGIN{

     print "<html> \n <body> \n <tabel cellpadding="10" border="1">

     Print "<h5> Memory Details </h5>

     }

     {

     print "<tr>"

     for(i=1;i<=NF;i++)

     print "<td bgcolor=yellow>" $i "</td>"

     print "</tr>"

     }

     {

     print "<tr>"

     for(j=1;j<=NF;j++)

     print "<td>" $j "</td>"

     print "</tr>"

     }

     i=0;

End{

print "\n</table> /n<body> /n <html>"

} Memory.txt > test.html

Is it possible to read  data from a particular line ( second line ) for this scenario

Any suggestions.

Thanks,

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 22 2017
Added on Oct 25 2017
3 comments
3,159 views