I have this bash script on my CentOS 5.3.
#!/bin/bash
RESULT=$(cat /tmp/logfile.log | grep -i "Backlog File Count" | awk '{print $6}')
if [ "${RESULT}" -lt "5" ];
then
echo "${RESULT} is less than 5"
else
echo "${RESULT} is greater than 5"
fi
/tmp/logfile.log:
Backlog File Names (first 1 files)
This bash script should supposedly to get the value "1" on the log file and print the output. However, when I run the script, this is the error message:
: integer expression expected
So when I set the debug mode, I found the "RESULT" variable output:
+ RESULT=$'1\r' ..... + '[' $'1\r' -lt 5 ']'
I've noticed that "\r" output is attached on the value.
I would appreciate if any one could lead me why there is "\r" on that output and how to get rid of that error. I tried on CentOS 6.3 and there is no issue.
# rpm -qa bash bash-3.2-32.el5_9.1
Thank you. James