Linux笔记-shell遍历数组并判断是否等于某个值
如下脚本:for i in "${!DataList[@]}";docurrentStr="${DataList[$i]}"#echo $currentStr#分析程序if [ ${currentStr} == "xxxx_yyyy_qqqq" ];then#TODO STH
·
如下脚本:
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
更多推荐
已为社区贡献22条内容
所有评论(0)