Progkör beadandóm :D

Amúgy meg ezt már beadtam. 

#Kornyezeti valtozok letrehozasa es default ertekek beallitasa
TABCHAR="";
EGYEDITAB='0';
VANTAB='0';
title=''
h3=''
thead=''
thead_align=''
x='0';
function parameterhiba ()
{
echo "A program parameterezse hibas, vagy a paraméterként megadott adat nem fájl. Tovabbi informacioert hivja meg a $0 -- help parancsot!" >&2
exit 1
}
#Beolvassa a standard inputra kuldott sorokat>==================================
function readinput ()
{
LINE=0
DataLine=0
while read line
    do
    SOROK[$LINE]=$line
        let "LINE = $LINE + 1"
    if [ $(echo "$line" | cut "-c1") =  '<' ]
    then
        let "DataLine = $DataLine + 1"
    fi
    done
OSZLOPOK=$(if [ "$EGYEDITAB" = '1' ]
        then
        echo "${SOROK[$DataLine]}" | sed "s/""$TABCHAR""/\n/g" | wc -l
        else
        echo "${SOROK[$DataLine]}" | sed "s/\    /\n/g" | wc -l    
        fi)
}
function htmlhead ()
    {
    echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"
    echo "<html><head>"
    echo "<meta content=\"text/html; charset=ISO-8859-2\" http-equiv=\"content-type\">"
    echo "<style type=\"text/css\">"
    echo "  body {scrollbar-base-color:green; font: small Arial, Verdana, Helvetica, sans-serif; background: #deb887; padding: 1px 1px; margin:0px;}"
    echo "  h3 {color: #000000; font-size: medium; padding: 3px; margin: 0px;}"
    echo "  h4 {color: #000000; font-size: small; padding: 2px; margin: 0px;}"
    echo "  a:link, a:visited, a:active {color: 0000ff; text-decoration: none}"
    echo "  div.tableContainer {scrollbar-base-color:green; height: 100%; overflow: auto; margin: 0 auto; border: 0; direction: rtl;}"
    echo "  table {direction: ltr;}"
    echo "  table.szaz {width: 100%; height: 100%; border: 0;}"
    echo "  td.szaz {border:0; background: transparent;}"
    echo "  thead th {background-color: #7cfc00; position:relative; top: expression(document.getElementById(\"data\").scrollTop-1);}"
    echo "  tfoot th {background-color: #7cfc00; font-weight: normal; color: gray;}"
    echo "  th {font: small Arial, Verdana, Helvetica, sans-serif; font-weight: bold; border: #222222 1px solid; background-color: #fffacd; color: #000000;}"
    echo "  td {font: small Arial, Verdana, Helvetica, sans-serif; border: #222222 1px solid; background-color: #ffffff; color: #000000;}"
    echo "  th.ures_sor, td.ures_sor {height: 8px; border: 0px; background: transparent;}"
    echo "  th.ures, td.ures {border: 0px; background: transparent;}"
    echo "</style>"
    echo "<style type=\"text/css\" media=\"print\">"
    echo "  div.tableContainer {overflow: visible;}"
    echo "  thead {display: table-header-group;}"
    echo "  tfoot {display: table-footer-group;}"
    echo "  thead th, thead td {position: static;}"
    echo "</style>"
    echo "<title>$title</title>"
    echo "</head>"
    echo ""
    echo "<body onLoad=\"document.location.hash = 'tabla';\">"
    echo "<div id=\"container\"><center>"
    echo ""
    echo "<table>"
    echo "  <tr><th colspan=$OSZLOPOK align=center><h3><a href=\"#tabla\">$h3</a></h3></th></tr>"
    echo "</table>"
    echo "<table>"
    echo "  <tr><td class=ures_sor></td></tr>"
    echo "</table>"
    echo ""
    echo "<table class=szaz><tr><td class=szaz align=center>"
    echo "<div class=\"tableContainer\" id=\"data\"><a name=tabla></a>"
    echo "<table border=0 cellpadding=2 cellspacing=1>"
    echo "  <thead>"
    echo "    <tr>$thead</tr>"
    echo "    <tr><th class=ures_sor></th></tr>"
    echo "  </thead>"
    echo "  <tbody>"
    }
    #Megjeleniti a sugo szoveget>==================================================
    function helpkiiras ()
    {
    echo "Szoveg -> HTML tablazat konverter script"
    echo "Hasznalat $0 [--help] [-tX] [fajlnev]"
    echo " "
    echo " -tX        :(opcionalis) X helyere a Tabulator karakter helyett"
    echo "             hasznalni kivant karaktert kell beirni. Amennyiben"
    echo "             a parametert nem adjuk meg, ugy alapertelmezetten a"
    echo "             TABulator karakter kerul kivalasztasra. Ezt a parametert"
    echo "             csak elso parameterkent adhatjuk meg."
    echo " --help     :(opcionalis) Csak a sugo megjelenitese a hasznalatrol."
    echo " [fajlnev]  :(opcionalis) Amennyiben megadjuk egy fajl nevet, ugy azt"
    echo "             hasznalja bemeneti forrasknet, kulonben a standard inputot."
    echo "             A fajlnev parameter csak utolso helyen szerepelhet a"
    echo "             parameterek kozott."
    exit 0
}
##THTML fájl vége sablon
function htmlend ()
{
echo '  </tbody>'
echo '</table></div></td></tr></table></center></div></body></html>'
}
##HTML Táblázat gererálása
function tablegen ()
{
##Generálás akkor, ha nincs thread_align megadva
if [ "$thead_align" = '' ]
then
    for ((i="$DataLine";i<="$LINE"-1;i++))
    do
    if [ $EGYEDITAB = '1' ]
        then
        if [ $(echo "${SOROK[i]}" | cut "-c1") != "<" ]
            then
            echo -n "    <tr><td align=left>"
            echo -n "${SOROK[i]}" | sed "s/$TABCHAR/<\/td><td align=left>/g"
            echo '</td></tr>'
            fi
        else
        if [ $(echo "${SOROK[i]}" | cut "-c1") != "<" ]
            then
            echo -n "    <tr><td align=left>"
            echo -n "${SOROK[i]}" | sed "s/\    /<\/td><td align=left>/g"
            echo '</td></tr>'
            fi
        fi
    done
else
    #Rendezés thread_align megadása esetén
    ##Rendezési adatok beolvasása
    for ((i=1;i<=$(echo "$thead_align" | wc "-c")-1;i++))
        do
        if [ $(echo "$thead_align" | cut "-c$i") = 'L' ]
            then
            RENDEZES[$i]='left'
            fi
        if [ $(echo "$thead_align" | cut "-c$i") = 'R' ]
            then
            RENDEZES[$i]='right'
            fi
        if [ $(echo "$thead_align" | cut "-c$i") = 'C' ]
            then
            RENDEZES[$i]='center'
            fi
        done
    ##Táblázat kiírása rendezetten
        for ((i="$DataLine";i<="$LINE"-1;i++))
        do
        if [ $(echo "${SOROK[i]}" | cut "-c1") != "<" ]
            then
            X='1'
            echo -n "    <tr>"
            ##Adatok beolvasása az elválasztókarakterrel elválasztva
            if [ $EGYEDITAB = '1' ]
                then
                echo "${SOROK[i]}" | sed "s/""$TABCHAR""/\n/g" | while read adatka
                        do
                    echo -n "<td align=${RENDEZES[$X]}>$adatka"
                    echo -n "</td>"
                    let "X = $X + 1"
                        done
                else
                echo "${SOROK[i]}" | sed "s/\    /\n/g" | while read adatka
                        do
                    echo -n "<td align=${RENDEZES[$X]}>$adatka"
                    echo -n "</td>"
                    let "X = $X + 1"
                        done
                fi
                echo '</tr>'
            fi
        done
fi
}
#--help parameter eseten megjeleniti a sugot
if [ "$1" = "--help" ]
then
    helpkiiras
    exit 0
fi
function pharasehead ()
{
    title=$(for ((i=0;i<="$LINE";i++))
    do
    echo "${SOROK[i]}" | fgrep '<title>' | sed 's/<title>//g'
    done)
    h3=$(for ((i=0;i<="$LINE";i++))
    do
    echo "${SOROK[i]}" | fgrep '<h3>' | sed 's/<h3>//g'
    done)
    thead_align=$(for ((i=0;i<="$LINE";i++))
    do
    if [ $EGYEDITAB = '1' ]
        then
        echo "${SOROK[i]}" | fgrep '<thead_align>' | sed 's/<thead_align>//g' | sed "s/$TABCHAR//g"
        else
        echo "${SOROK[i]}" | fgrep '<thead_align>' | sed 's/<thead_align>//g' | sed "s/\    //g"
        fi
    done)
    ##Thead kiértékelése
    thead=$(if [ "$thead_align" = '' ]
        then
        for ((i=0;i<="$LINE";i++))
              do
            if [ "$(echo -n "${SOROK[$i]}" | cut "-c-7")" = '<thead>' ]
            then
            if [ $EGYEDITAB = '1' ]
                then
                echo -n "<th align=left>${SOROK[$i]}</th>" | fgrep '<thead>' | sed 's/<thead>//g' | sed "s/$TABCHAR/<\/th><th align=left>/g"
                else
                echo -n "<th align=left>${SOROK[$i]}</th>" | fgrep '<thead>' | sed 's/<thead>//g' | sed "s/\    /<\/th><th align=left>/g"
                fi
            fi
                done
        else
        for ((i=1;i<=$(echo "$thead_align" | wc "-c")-1;i++))
            do
            if [ $(echo "$thead_align" | cut "-c$i") = 'L' ]
                then
                RENDEZES[$i]='left'
                fi
            if [ $(echo "$thead_align" | cut "-c$i") = 'R' ]
                then
                RENDEZES[$i]='right'
                fi
            if [ $(echo "$thead_align" | cut "-c$i") = 'C' ]
                then
                RENDEZES[$i]='center'
                fi
            done
                for ((i=0;i<="$LINE";i++))
              do
            for ((i=0;i<="$LINE";i++))
                  do
                X=1;
                if [ $EGYEDITAB = '1' ]
                    then
                    echo "${SOROK[i]}" | fgrep '<thead>' | sed 's/<thead>//g' | sed "s/""$TABCHAR""/\n/g" | while read adatka
                                                    do
                                                    echo -n "<th align=${RENDEZES[$X]}>$adatka</th>"
                                                    let "X = $X + 1"
                                                    done
                    else
                    echo "${SOROK[i]}" | fgrep '<thead>' | sed 's/<thead>//g' | sed "s/\    /\n/g" | while read adatka
                                                    do
                                                    echo -n "<th align=${RENDEZES[$X]}>$adatka</th>"
                                                    let "X = $X + 1"
                                                    done
                    fi
                    done
                done
        fi)

}
# Beolvassa a tabulator karaktert a TABCHAR valtozoba
TABCHAR=$(echo -n "$1" | cut "-c-2" | while read line
    do
    if [ "$line" = '-t' ]
    then
    echo "$1" | cut "-c3" | tee
    fi
    done | cut -c1 | tee)
if [ "$#" = "0" ]
    then
    VANTAB='1'
    fi
if [ "$TABCHAR" != '' ]
then
    VANTAB='1'
    EGYEDITAB='1'
fi
if [ -e "$1" ]
then
    if [ -d "$1" ]
    then
        parameterhiba    
    fi
        cat "$1" | "$0"
        exit $?
fi
if [ -e "$2" ]
then
    if [ -d "$2" ]
    then
        parameterhiba    
    fi
    cat "$2" | "$0" "$1"
    exit $?
fi
##Hibás paramrerezés esetén ide jut:
if [ "$VANTAB" = '0' ]
    then
    parameterhiba
    fi
# Forras beolvasa
readinput
#HTML felso resze adatainak kigyujtese
pharasehead
#HTML kd generlsa a fjl elejhez
htmlhead
## A táblázathoz
tablegen
## És a végéhez
htmlend