Bash shell脚本html css

vi4fp9gy  于 2023-02-05  发布在  Shell
关注(0)|答案(1)|浏览(137)
while read row do
    echo "<tr>" >> $file
    for valore in $row 
    do
        echo "<td>$valore</td>" >> $file
    done
        echo "</tr>" >> $file
done < alunni.txt
    echo "</table>" >> $file

当我执行这段代码时,它给出了这个错误:

./table_html.csv: line 36: syntax error near unexpected token `echo'
./table_html.csv: line 36: `            echo "<td>$valore</td>" >> $file'

我该怎么补救?
我不太擅长shell脚本,这就是为什么我想不出别的。

qrjkbowd

qrjkbowd1#

(Ah当烤箱的闹钟响的时候,我正在做这个。我想说的是,这只是“do”在错误的地方,所以这里是你的代码重述(添加了一个file=“filename”来让它工作):

file="test2.html"
while read row 
do
    echo "<tr>" >> $file
    for valore in $row 
    do
        echo "<td>$valore</td>" >> $file
    done
        echo "</tr>" >> $file
done < alunni.txt
    echo "</table>" >> $file

所以这只是一个换行符之前,做是所有你需要的:-)

相关问题