Dieses Stück Code funktioniert absolut in Ordnung, wenn ich es individuellfür Block innerhalb bash
for i in {1..13}
do
echo "<td class = 'loop'>
</td>"
done
bin Ausführung Aber wenn ich dies in einem Bash-Skript bin Putting Ich bin nur eine Iteration bekommen, statt 13 Iteration.
Das ganze Skript sieht so etwas wie
while read variable
do
//something
done<a.txt
for i in {1..13}
do
echo "<td class = 'loop'>
</td>"
done
Kann jemand mir helfen.
EDIT
#/!/bin/bash
while read host
do
y=$(($y+1))
count=$(ping -c $COUNT $host | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ $count -eq 0 ]; then
if [ -n "$host" ]; then
echo "<td class ='statuscellred'>" >>table1.html
echo "$host" | cut -d'.' -f1 >> table1.html
echo "</td>" >> table1.html
if [ $(($y % 13)) -eq 0 ] ; then
echo "</tr>">>table1.html
echo "<tr>">>table1.html
fi
else
echo "<td class ='statuscellblanck'>" >>table1.html
echo "$host" >> table1.html
echo "</td>" >> table1.html
if [ $(($y % 13)) -eq 0 ] ; then
echo "</tr>">>table1.html
echo "<tr>">>table1.html
fi
fi
else
if [ -n "$host" ]; then
echo "<td class ='statuscellgreen'>" >>table1.html
echo "$host" | cut -d'.' -f1 >> table1.html
echo "</td>" >> table1.html
if [ $(($y % 13)) -eq 0 ] ; then
echo "</tr>">>table1.html
echo "<tr>">>table1.html
fi
else
echo "<td class ='statuscellblanck'>" >>table1.html
echo "$host" >> table1.html
echo "</td>" >> table1.html
if [ $(($y % 13)) -eq 0 ] ; then
echo "</tr>">>table1.html
echo "<tr>">>table1.html
fi
fi
fi
done < server1.txt
for i in {1..13}
do
echo "<td class = 'loop'>
</td>">>table1.html
done
und hier server1.txt ist
1.com
2.com
3.com
4.com
5.com
7.com
8.com
9.com
11.com
13.com
15.com
ich normalerweise 'for i in' $ (Seq 1 13) und ich bin sicher, dass es funktioniert. –
Ist das der * aktuelle * Code? –
der eigentliche Code ist größer als das. Aber Logikteil ist nur so viel.Wollen Sie den gesamten Code einfügen? – Monojit