我有像
这样的清单list = ['pic1','pic2','pic3'];
我就像
一样for a in /dir/star
if(a is in list then skip the loop)
do
echo "hello";
done
如果元素在列表
中,我想跳过循环答案 0 :(得分:0)
for path in /dir/*
do
for val in pic1 pic2 pic3
do
if [ "$(basename -- "$path")x" = "${val}x" ]
then
continue 2 # Next path
fi
done
# No match, do whatever you want
done
如果您想在找到第一个匹配项后完全结束处理,只需将continue
替换为break
。