我的if语句没有发挥应有的作用,我也不明白为什么。
这就是我所拥有的
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当我对IF语句使用-eq时,程序会显示这个UP^M: 0403-009 The specified number is not valid for this command.
有什么主意吗?
编辑。找到了答案:
出于某种原因,程序在末尾添加了一个返回字符。
添加以下内容:获得列值后的inst=$(echo $inst | tr -d '\r')解决了这个问题。
发布于 2012-07-24 20:49:53
找到了答案:
出于某种原因,程序在末尾添加了一个返回字符。
添加以下内容:获得列值后的inst=$(echo $inst | tr -d '\r')解决了这个问题。
发布于 2012-07-23 13:43:25
源文件上的dos2 unix也可能有所帮助,someFile.txt
https://stackoverflow.com/questions/11613663
复制相似问题