Gawk

array2html script

#!/usr/bin/gawk -f
# ___  _  _ ____ ___ ___ ____ ___  ____
# |  \ |  | |     |   |  |__| |__] |___
# |__/ |__| |___  |   |  |  | |    |___
#
# The scripts were written to be usefull in
# a research enviornment, but anyone is welcome
# to use them.  Happy awking.  -Tim Sherwood
 
BEGIN {
    FS =":";
    printf  "%s%s%s",
        "<TABLE cellpadding=\"1pt\" BORDER=\"2pt\" ",
        "CELLSPACING=\"0pt\" bgcolor=\"\#ffffff\" ",
        "bordercolor=\"\#000000\">\n";
 
}
 
(NR==1){
    printf "   <TR bgcolor=\"\#dfdfdf\">\n"
    for( i=1; i<=NF; i++ )
    {
        printf "      <TD><center>%s</center></TD>\n", $i;
    }
    printf "   </TR>\n"
}
 
(NF>0 && NR>1){
 
    printf "   <TR>\n"
    for( i=1; i<=NF; i++ )
    {
        if ( i==1 ) {
            printf "      <TD align=left>%s</TD>\n", $i;
        } else {
            printf "      <TD align=right>%s</TD>\n", $i;
        }
    }
    printf "   </TR>\n"
}
 
END {
    printf "</TABLE>\n";
}
/home1/yepnnet/public_html/wiki/data/pages/gawk.txt · 最后更改: 2010/01/27 03:01 由 admin
到顶部
CC Attribution-Noncommercial-Share Alike 3.0 Unported
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0