Open junxnone opened 2 years ago
for((i=1;i<=10;i++)); do echo $(expr $i \* 3 + 1); done
..
for i in {1..10} do echo $(expr $i \* 3 + 1); done
for i in $(seq 1 10) do echo $(expr $i \* 3 + 1); done
for i in $* ; do echo $i is input chart\! ; done
for i in f1 f2 f3 ; do echo $i is appoint ; done
list="rootfs usr data data2" for i in $list; do echo $i is appoint ; done
# 定义一个数组变量 fruits=("Apple" "Banana" "Orange" "Grapes") # 使用for循环遍历数组元素 for fruit in "${fruits[@]}"; do echo "Fruit: $fruit" done
for file in /proc/*; do echo $file is file path \! ; done
for file in $(ls *.sh) do echo $file is file path \! ; done
for i in `ls`; do echo $i is file name\! ; done
Shell for
数字循环
i++
..
生成遍历区间值seq 生成遍历区间值
变量循环
输入参数遍历
遍历多个变量
遍历变量中的字符串
遍历数组
遍历路径匹配
遍历命令执行结果
Reference