如下脚本:

for i in "${!DataList[@]}";

        do
                currentStr="${DataList[$i]}"
                #echo $currentStr
                #分析程序
                if [ ${currentStr} == "xxxx_yyyy_qqqq" ];
                        then
							#TODO STH
							......
							......
                        fi

                done

这里的DataList为shell的数组。

下面是转成整形进行处理:

currentValue="${DataList[$i+1]}";
currentValue=$currentValue
currentValue=$((currentValue))

#这里最大不能大于4,如果大于4就 ... ... ... ...
if [ $currentValue -gt "4" ];
	then
	#TODO something
    ......
    ......
fi

 

Logo

更多推荐