shell 练习(for,while,until,local)
2015-05-28 16:49
369 查看
#!/bin/bash for variable1 in 1 2 3 4 5 do echo "Hello,Welcome $variable1 times" done for var in {1..5} do echo "index $var" done sum=0 for i in {1..100..2} do let "sum+=i" done echo "sum=$sum" sum=0 for i in $( seq 1 2 100 ) do let "sum+=i" done echo "sum=$sum" for file in $( ls ) do echo "file: $file" done echo "number of arguments is $#" echo "What you input is:" for argument in "$*" do echo "$argument" done for(( i=1;i <= 5;i++)) do echo "$i" done echo "=====================================\n" int=1 while(( "$int" <= 5 )) do echo "$int" let "int++" done i=0 until [[ "$i" -gt 5 ]] do let "square=i*i" echo "$i*$i=$square" let "i++" done
#!/bin/bash text="global variable" use_local_var_fun() { local text="local variable" echo "In function use_local_var_fun" echo $text } echo "Execute the function use_local_var_fun" use_local_var_fun echo "out of function use_local_var_fun" echo "$text" exit 0
相关文章推荐
- Shell 脚本之循环语句(for,while,until)以及case,select,break,continue实例详解
- [Shell]条件判断与流程控制:if, case, for, while, until
- shell的一些常用的语句(if语句,变量,for、while、until语句、函数调用、脚本调用)
- Shell脚本中循环语句for,while,until用法
- 编写三个Shell程序,分别用for、while、与until求从2+4+…+100的和。
- Shell中的循环语句for、while、until实例讲解
- Shell中的循环语句总结(for, while, until)
- Shell脚本中循环语句for,while,until用法
- shell实例讲解while、for、until、if等
- shell脚本下的循环语句for、while、until
- shell编程控制结构:expr、let、for、while、until、shift、if、case、break、continue、函数、select .
- shell 脚本 之循环 for while until 和 软件包的管理 【上】
- 一文读懂Shell脚本中循环语句for,while,until用法
- Shell Scripts - 循环while,until,for
- shell循环,for 、while、until
- shell编程控制结构:expr、let、for、while、until、shift、if、case、break、continue、函数、select
- shell 编程之 for while until 循环
- shell脚本之循环语句for,while,until用法的详解
- Shell Scripts - 循环while,until,for
- shell编程控制结构:expr、let、for、while、until、shift、if、case、break、continue、函数、select