#/bin/sh
定义数据
ary=('item0' 'item1' 'item2')
v='item0'
white1=(1 2)
white2=(11 22)
#判断ary数组中是否包含v
if echo "${ary[@]}" | grep -w "${v}"
then
echo "yes"
else
echo "no"
fi
#输出数组white1的长度
echo ${#white1[@]}
#遍历white1数组
for(( i=0;i<${#white1[@]};i++))
do
echo "index:"$i
#输出white2中对应下标的值
echo ${white2[i]}
#跳出循环
if [ $i -eq 1 ]; then
break
fi
done
shell数据遍历
最新推荐文章于 2025-10-29 21:18:10 发布
505

被折叠的 条评论
为什么被折叠?



