Artificial intelligent assistant

if condition always evaluating true 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 In the above, only first condition is evaluating to be true even when `${fin[2]}` is not equal to OK. What's wrong?

The operators `-eq` and `-ne` are _arithmetic_ operators for comparing _numerical_ data.

What you want here is `==` and `!=`:


if [[ "${fin[2]}" == 'OK' ]] &&
[[ "${fin[7]}" == 'NA' ]]; then


and


elif [[ "${fin[2]}" != 'OK' ]] &&
[[ "${fin[7]}" == 'NA' ]] &&
(( currDate2 < expectedFinishTimes )); then


(for example).

* * *

Also, be careful with your quoting and `echo`:


echo ""


is better written as


echo ''


The first will produce





while the second will produce


xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 132da3dac60767d26f929d548764f25c