
if [[ ${fin[2]} -eq OK && ${fin[7]} -eq NA ]]
then
echo "<tr id="green">" >> /tmp/mailt.txt
elif [[ ${fin[2]} -eq OK && ${fin[7]} -lt 0 ]]
then
echo "<tr id="yellow">" >> /tmp/mailt.txt
elif [[ ${fin[2]} -ne OK && ${fin[7]} -eq NA && $currDate2 -gt $expectedFinishTimes ]]
then
echo "<tr id="red">" >> /tmp/mailt.txt
elif [[ ${fin[2]} -ne OK && ${fin[7]} -eq NA && $currDate2 -lt $expectedFinishTimes ]]
then
echo "<tr id="white">" >> /tmp/mailt.txt
fi
上記の場合、${fin[2]}
OKと同じでなくても、最初の条件のみがtrueと評価されます。何が問題なの?
答え1
オペレーター様-eq
、そう-ne
です。山水比較に使用される演算子数値データ。
あなたが望むものは次==
のとおりです!=
。
if [[ "${fin[2]}" == 'OK' ]] &&
[[ "${fin[7]}" == 'NA' ]]; then
そして
elif [[ "${fin[2]}" != 'OK' ]] &&
[[ "${fin[7]}" == 'NA' ]] &&
(( currDate2 < expectedFinishTimes )); then
(例えば)。
また、引用符と次の点を参照してくださいecho
。
echo "<tr id="green">"
次のように書く方が良いです。
echo '<tr id="green">'
最初は生産します
<tr id=green>
セカンド製品の生産中
<tr id="green">