I'm having real trouble getting my script to work, it's about 3 pages long and I'm having trouble with one of my if...then constructs. The code for the sub is as follows:
check_a_b () {
CHECKA="634274"
CHECKB="512274"
if [ CHECKA=CHECKB ]; then
echo "Match"
echo "$CHECKA" >> "$LOGFILE"
echo "$CHECKB" >> "$LOGFILE"
else
echo "No match"
echo "$CHECKA" >> "$LOGFILE"
echo "$CHECKB" >> "$LOGFILE"
fi
}
I'm running this script under MacOS X Darwin. The script above, when executed, prints "Match" ... although I'm fairly certain that CHECKA and CHECKB are different. If I remove the last space in the IF brackets, ie:
if [ CHECKA=CHECKB ]; then
becomes:
if [ CHECKA=CHECKB]; then
Then it prints "No match", and cannot be coaxed into printing "Match", even when I use:
if [ CHECKA=CHECKA]; then
I'm really confused! :cry:
Thanks in advance ...