while循环

#!/bin/bash
i=1
s=0
while [ $i -le 100 ]
do
s=$(($s+$i)) ##变量运算
i=$(($i+1))
done echo "1+2+3+...+100=$s"

  

until循环

i=1
s=0
until [ $i -ge 100 ] ##条件不成立才循环
do
s=$(($s+$i))
i=$(($i+1))
done echo "1+2+3+...+100=$s"

  

【shell】while与until循环的更多相关文章

  1. shell脚本之for循环

    shell脚本之for循环 author :headsen  chen       2017-10-18    09:50:41 个人原创,转载请注明.否则依法追究法律责任 1,cat forloop ...

  2. shell 脚本中所有循环语法

    写出 shell 脚本中所有循环语法 for 循环 : for i in $(ls);do echo item:$i done while 循环 : #!/bin/bash COUNTER=0 whi ...

  3. centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课

    centos  shell脚本编程2 if 判断  case判断   shell脚本中的循环  for   while   shell中的函数  break  continue  test 命令   ...

  4. shell脚本中select循环语句用法

    shell脚本中select循环语句 1. 脚本中select的语法格式 select VAR in LIST do command1 command2 ... ... commandN done s ...

  5. shell编程基础(5)---循环指令

    while类型的循环 while类型的循环是不定循环的一种,每一次循环都会验证给出的循环条件,判断是否要进行下一次循环.linux中while循环的写法和c语言中很想,但是条件给出的方式有些区别. 首 ...

  6. shell 脚本中for循环

    昨天很痛苦的搞了一天的for循环,在服务器上运行没啥问题,在设备上运行总是不行,部分代码如下: for(i=1;i<$cnt+1;i++)do echo "xxxx"  &g ...

  7. shell脚本进阶之循环判断

    p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; text-align: justify; f ...

  8. Shell脚本- 单条命令循环执行重复工作

    关于shell for循环具体详细说明可参考:http://wiki.jikexueyuan.com/project/linux-command/chap34.html example: 分别在com ...

  9. shell编程学习笔记(十):Shell中的for循环

    shell编程中可以实现for循环遍历 先来写一个最简单的吧,循环输出从1到10,脚本内容为: #! /bin/sh for i in {1..10} do echo $i done 上面的代码从1到 ...

  10. shell流程控制与循环结构

    shell脚本中的流程控制有if/else语句.case语句,循环结果包括for循环.while循环.until循环等内容. if语句 (1)最简单的if语句.使用格式有2种方式,分别如下 使用格式1 ...

随机推荐

  1. 不要在类的函数中使用static字段

    昨天在做存储服务的压力测试,后台是采用多线程根据玩家唯一标识做线程划分的,在测试的过程中发现,进行存储的时候,会发生玩家数据错乱的情况. 一开始怀疑是上层逻辑在处理数据的时候发生了错乱,导致保存的时候 ...

  2. 【题解】【BST】【Leetcode】Validate Binary Search Tree

    Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as ...

  3. c++ encode decode

    std::string UrlEncode(const std::string& szToEncode) { std::string src = szToEncode; char hex[] ...

  4. map的相关

    private static final Map<String, String> flagMap = new HashMap<String, String>(); static ...

  5. 209. Minimum Size Subarray Sum

    Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

  6. ZOJ 1068 P,MTHBGWB

    原题链接 题目大意:给定一个字符串,先用Morse Code编码,把编码倒序,再解码成字符串.现给定处理后的字符串,求原始信息. 解法:用C++String类的函数.每次读入一个字符,就在string ...

  7. hive学习笔记_hive的表创建

    创建hive表注意事项 一.表分隔符必须与读取的数据文件一致,比如例子的分隔符为 '\t'(制表符),hive下默认分隔符是制表符. 二.最好指定分区作为数据之间的区分. 三.创建完表可以desc+表 ...

  8. URAL Mosaic(并查集)(欧拉回路)

    Mosaic Time limit: 0.25 secondMemory limit: 64 MB There's no doubt that one of the most important an ...

  9. HDU-5785 Interesting(Manacher算法+区间处理)

    题目大意:给一个字符串,求所有相邻两回文子串的外侧下标之积的和 题目分析:另L[i]为所有以 i 为右端点的回文字串的左端点之和,同理,另R[i]表示所有以 i 为左端点的回文子串的右端点之和.显然, ...

  10. hihoCoder#1055 : 刷油漆 (树形DP+01背包)

    题目大意:给一棵带点权的树,现在要从根节点开始选出m个连通的节点,使总权值最大. 题目分析:定义状态dp(u,m)表示在以u为根的子树从根节点开始选出m个点连通的最大总权值,则dp(u,m)=max( ...