前言

用bash shell写程序时,经常会用到for循环,特别是从1到100这种需求,这里记录几种shell中从1到100的循环方法
 

方法

类c语言

  1. for ((i=1; i<=100; i ++))
  2. do
  3. echo $i
  4. done
for ((i=1; i<=100; i ++))
do
echo $i
done

in使用

  1. for i in {1..100}
  2. do
  3. echo $i
  4. done
for i in {1..100}
do
echo $i
done

seq使用

作用

  1. seq - print a sequence of numbers
seq - print a sequence of numbers

代码

  1. for i in `seq 1 100`
  2. do
  3. echo $i
  4. done

bash shell for循环1到100 .的更多相关文章

  1. bash shell for循环

    1 同c一样用四个空格进行缩进 2 每行一条语句,不用分号 3 不用大括号标识代码块,但是要用do/done来标识代码块 4 用双小括号,类似于c的for进行编码 for ((i=1; i<=1 ...

  2. bash/shell编程学习(3)

    接上节继续, 1. 从键盘读取输入内容 #!/bin/bash read -p 'please input something:' input echo 'your input:' $input 运行 ...

  3. bash shell命令(2)

    在上篇<bash shell命令(1)>中,介绍了几种简单的linux shell命令,今天继续介绍bash shell命令 本文地址:http://www.cnblogs.com/arc ...

  4. linux之bash shell

    GNU bash ======================================================== 通常计算机硬件是由运算器.控制器.存储器.输入/输出设备等等这些物理 ...

  5. [转帖][Bash Shell] Shell学习笔记

    [Bash Shell] Shell学习笔记 http://www.cnblogs.com/maybe2030/p/5022595.html  阅读目录 编译型语言 解释型语言 5.1 作为可执行程序 ...

  6. Bash Shell 小试牛刀

    一.终端打印 [root@cai ~]# echo welcome to bash! welcome to bash! [cairui@cai ~]$ echo 'welcome to bash!' ...

  7. Linux shell for循环结构

    Linux Shell   for循环结构 循环结构            1:循环开始条件      2:循环操作      3:循环终止的条件 shell语言          for,while ...

  8. Linux 之Shell for循环

    @代表所有参数所以如果后面跟上echo $v你会发现他会一次显示user userdebug eng $poo -le ${#prodlist[@]} 这句话是说 $poo小于等于prodlist中的 ...

  9. Shell while循环详解

    while 循环是 Shell 脚本中最简单的一种循环,当条件满足时,while 重复地执行一组语句,当条件不满足时,就退出 while 循环. Shell while 循环的用法如下: while  ...

随机推荐

  1. URAL1009

    链接 第一道URAL题 简单递推 #include <iostream> #include<cstdio> #include<cstring> #include&l ...

  2. 阿里巴巴SUI Mobile的使用

    1.引入文件 <link rel="stylesheet" href="./css/sm.min.css"> <link rel=" ...

  3. ie调试器

    最大化影响调试的,点右上角的固定按妞

  4. c#调用c++动态库的一些理解

    调用c++动态库一般我们这样写   [DllImport("UCamer.dll", CallingConvention = CallingConvention.Winapi)] ...

  5. VS2012、VS2010、VS2008常用的快捷键

    下面为大家带来VS各个版本常用的快捷方式,希望对大家开发过程中有帮助: 强迫智能感知:Ctrl+J: 强迫智能感知显示参数信息:Ctrl-Shift-空格: Ctrl+E,D ----格式化全部代码 ...

  6. BrnShop开源网上商城第六讲:扩展视图功能

    在正式讲解扩展视图功能以前,我们有必要把视图的工作原理简单说明下.任何一个视图都会被翻译成一个c#类,并保存到指定的位置,然后被编译.这也就是为什么能在视图中包含c#代码片段的原因.下面我们通过一个项 ...

  7. [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.2.5

    Show that matrices with distinct eigenvalues are dense in the space of all $n\times n$ matrices. (Us ...

  8. ifconfig命令

    许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...

  9. FlexSlider插件的详细设置参数 http://www.woothemes.com/flexslider/

    http://www.woothemes.com/flexslider/ FlexSlider插件的详细设置参数 $(window).load(function() { $('.flexslider' ...

  10. 字符串逆转(递归和非递归java)

    package 乒乒乓乓; public class 递归逆转字符串 {    //非递归逆转    public static String reverse(String s)    {       ...