Linux-Bash-Loops-branch

for

# 等价于 for para in $@
for para
do
  echo "$para"
done

# 当前目录下的 txt 文件
for file in *txt
do 
  echo $file
done 

select

# 如果 in list 省略,将使用 $@
select variable [in list]
do 
 command... 
 break 
done

# 

PS3='Choose your favorite vegetable: '
select veg in "beans" "carrots" "potatoes"
do
    if [ -z $veg ]
    then
        echo "Sorry. That is not on the menu."
        continue
    else
        echo
        echo "Your $veg"
        echo
    fi
    break
done

你可能感兴趣的:(Linux-Bash-Loops-branch)