#!/bin/bash
my_arry=(a b "c","d" abc)
echo "-------FOR循环遍历输出数组--------"
for i in ${my_arry[@]};
do
echo $i
done echo "-------::::WHILE循环输出 使用 let i++ 自增:::::---------"
j=0
while [ $j -lt ${#my_arry[@]} ]
do
echo ${my_arry[$j]}
let j++
done echo "--------:::WHILE循环输出 使用 let "n++ "自增: 多了双引号,其实不用也可以:::---------"
n=0
while [ $n -lt ${#my_arry[@]} ]
do
echo ${my_arry[$n]}
let "n++"
done echo "---------::::WHILE循环输出 使用 let m+=1 自增,这种写法其他编程中也常用::::----------"
m=0
while [ $m -lt ${#my_arry[@]} ]
do
echo ${my_arry[$m]}
let m+=1
done echo "-------::WHILE循环输出 使用 a=$[$a+1] 自增,个人觉得这种写法比较麻烦::::----------"
a=0
while [ $a -lt ${#my_arry[@]} ]
do
echo ${my_arry[$a]}
a=$[$a+1]
done

shell 循环总结的更多相关文章

  1. Shell 循环中实现展示进度百分比的脚本方法

    Shell 循环中实现展示进度百分比的脚本方法 当我需要处理一个几万行的文件的时候,需要处理的时间是比较长的.我一开始的想法是,没处理一行,就输出一个 # 号.但是这样还是会出现很多很多的 # 号,即 ...

  2. For,while,case,shell循环结构

                                                                For,while,case,shell循环结构 案例1:使用for循环结构 案 ...

  3. Shell循环语句for、while、until

    Shell循环语句for.while.until            一.条件测试            二.删除字符            三.循环语句              示例1     ...

  4. Shell循环练习题

    Shell循环练习题 目录 Shell循环练习题 1.计算从1到100所有整数的和 2.提示用户输入一个小于100的整数,并计算从1到该数之间所有整数的和 3.求从1到100所有整数的偶数和.奇数和 ...

  5. Linux shell循环

    条件测试 格式 test condition 或 [ condition ] 使用方括号时,要注意在条件两边加上空格,如果有操作符,运算符之间也必须有空格 测试状态:测试的结果可以用$?的值来判断,0 ...

  6. shell 循环使用

    问题描述:                  shell中for循环while循环的使用 问题解决:              (1)for循环                      (1.1)数 ...

  7. 【Shell循环进程并行处理】利用简单的语句实现for循环并行处理命令

    在生信分析中,经常会遇到不同的重复和处理,这样的分析过程有时是非常费时且占用资源并不是很多的,可以同时在后台运行以节约时间,这是并行处理的意义.除了需要并行处理,循环迭代来遍历整个文件夹的需要分析的数 ...

  8. shell循环,判断介绍,以及实例

    shell的循环主要有3种,for,while,until shell的分支判断主要有2种,if,case 一,for循环 #!/bin/bash for file in $(ls /tmp/test ...

  9. shell循环结构解析:for/while/case

    1.for循环结构 for var in item1 item2 ... itemN do command1 command2 ... commandN done 例如,顺序输出当前列表中的数字: # ...

  10. shell 循环结构

    前言 循环结构在编程中十分常见,也是程序中是较为重要的一部分,在bash中有 for,until,while 这三种语句可以进行重复执行部分程序流程,下面会进一步讨论这三个指令的使用以及注意事项 fo ...

随机推荐

  1. POJ:2049Finding Nemo(bfs+优先队列)

    http://poj.org/problem?id=2049 Description Nemo is a naughty boy. One day he went into the deep sea ...

  2. POJ2485:Highways(模板题)

    http://poj.org/problem?id=2485 Description The island nation of Flatopia is perfectly flat. Unfortun ...

  3. numpy排序(sort、argsort、lexsort、partition、sorted)

    1.sort numpy.sort(a, axis=1, kind='quicksort', order=None) a :所需排序的数组 axis:数组排序时的基准,axis=0按行排列:axis= ...

  4. svg绘图工具raphael.js的使用

    1.raphael.js svg画图的开源库,支持IE8+ 官方api: http://dmitrybaranovskiy.github.io/raphael/reference.html Githu ...

  5. n的二进制中有几个1

    实例十七:n的二进制中有几个1 方法:result=n & (n-1)   n&(n-1)的目的使最低位的1不断翻转. 比如:n=108,其二进制表示为0110 1100,则n& ...

  6. git提交时候出错

    Please make sure you have the correct access rights and the repository exists. 解决方案: 主要原因是没有加载keygen ...

  7. python getatime() 查看文件的访问时间

    import time,os def main(): file_name=r'C:\Temp\Req.xml' file_times_access=time.localtime(os.path.get ...

  8. 计算概论(A)/基础编程练习1(8题)/7:奇数求和

    #include<stdio.h> int main() { // 输入非负整数 int m, n; scanf("%d %d", &m, &n); / ...

  9. js如何模拟multipart/form-data类型的请求

    var temp = document.createElement('form'); temp.action = this.data.testURL; temp.method = 'post'; te ...

  10. Linux学习笔记之Linux Centos关闭防火墙

    # Centos6.x /etc/init.d/iptables stop chkconfig iptables off sed -i 's/SELINUX=enforcing/SELINUX=dis ...