0
我有一个简单的if else
循环内while
,但它没有给我正确的输出需要。如果循环赢,而不工作在shell脚本
#!/bin/bash
set -x
inputFile=/data2/example/output1.txt
while read col1 col2 col3; do
if [ $col2=='Success' ]
then
echo " This is Green"
else
echo " This is Red"
fi
done < ${inputFile}
输出我得到的是:
+ read col1 col2 col3
+ '[' Success==Success ']'
+ echo ' This is Green'
This is Green
+ read col1 col2 col3
+ '[' Success==Success ']'
+ echo ' This is Green'
This is Green
+ read col1 col2 col3
+ '[' Failed==Success ']'
+ echo ' This is Green'
这不是进入else
部分,不断显示This is Green
。
这
那么,什么是你输入什么呢? – Danieboy