Possible Duplicate:
Bash: check if an array contains a value
i have list like
list = ['pic1','pic2','pic3'];
i am in array like
for a in /dir/star
if(a is in list then skip the 开发者_开发问答loop)
do
echo "hello";
done
I want to skip the loop if element is in list
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
If you want to end processing completely after finding the first match, just replace continue
with break
.
精彩评论