My if statement is not working as it should and I do not get why.
This is what I have
for LINE in $(cat someFile.txt)
do
inst=$(echo $LINE | awk -F, '{print $4}')
echo $inst # To verify is displaying correctly
if [ $inst == "UP" ]
then
echo "Program skips this when $inst is UP"
elif [ $inst == "DN" ]
then
echo "Program skips this when $inst is DN"
fi
done
And when I use -eq for the IF statement, the program displays this UP^M: 0403-009 The specified number is not valid for this command.
Any ideas??
EDIT. FOUND THE ANSWER:
For some reason the program is adding a return character at the end.
Adding this: inst=$(echo $inst | tr -d '\r') right after getting the column value resolves the issue.
FOUND THE ANSWER:
For some reason the program is adding a return character at the end.
Adding this:
inst=$(echo $inst | tr -d '\r')right after getting the column value resolves the issue.