美文网首页
Linux-Bash-Loops-branch

Linux-Bash-Loops-branch

作者: tarzipc | 来源:发表于2017-06-15 15:35 被阅读0次

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

      本文链接:https://www.haomeiwen.com/subject/roxuqxtx.html