【shell】while与until循环
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循环的更多相关文章
- shell脚本之for循环
shell脚本之for循环 author :headsen chen 2017-10-18 09:50:41 个人原创,转载请注明.否则依法追究法律责任 1,cat forloop ...
- shell 脚本中所有循环语法
写出 shell 脚本中所有循环语法 for 循环 : for i in $(ls);do echo item:$i done while 循环 : #!/bin/bash COUNTER=0 whi ...
- centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课
centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 ...
- shell脚本中select循环语句用法
shell脚本中select循环语句 1. 脚本中select的语法格式 select VAR in LIST do command1 command2 ... ... commandN done s ...
- shell编程基础(5)---循环指令
while类型的循环 while类型的循环是不定循环的一种,每一次循环都会验证给出的循环条件,判断是否要进行下一次循环.linux中while循环的写法和c语言中很想,但是条件给出的方式有些区别. 首 ...
- shell 脚本中for循环
昨天很痛苦的搞了一天的for循环,在服务器上运行没啥问题,在设备上运行总是不行,部分代码如下: for(i=1;i<$cnt+1;i++)do echo "xxxx" &g ...
- shell脚本进阶之循环判断
p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; text-align: justify; f ...
- Shell脚本- 单条命令循环执行重复工作
关于shell for循环具体详细说明可参考:http://wiki.jikexueyuan.com/project/linux-command/chap34.html example: 分别在com ...
- shell编程学习笔记(十):Shell中的for循环
shell编程中可以实现for循环遍历 先来写一个最简单的吧,循环输出从1到10,脚本内容为: #! /bin/sh for i in {1..10} do echo $i done 上面的代码从1到 ...
- shell流程控制与循环结构
shell脚本中的流程控制有if/else语句.case语句,循环结果包括for循环.while循环.until循环等内容. if语句 (1)最简单的if语句.使用格式有2种方式,分别如下 使用格式1 ...
随机推荐
- LeetCode Sum Root to Leaf Numbers(DFS)
题意: 给一棵二叉树,每个节点上有一个数字,范围是0-9,将从根到叶子的所有数字作为一个串,求所有串的和. 思路: 普通常规的DFS. /** * Definition for a binary tr ...
- Java Super 覆盖方法
子类从父类中继承方法,有时候,子类需要修改父类中定义的方法的实现,这称作方法覆盖. 比如,GeometricObject类中的toString方法返回表示集合对象的字符串,这个方法就可以被覆盖,返回表 ...
- 数组右移(C++)
数组A,右移k位,要求在线性时间内完成. #include <iostream> using namespace std; template <typename T> void ...
- linux 解压命令大全
.tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) --------------- .gz 解压 ...
- Google Translate CLI 筆記
$ trans -shell -brief > Rien ne réussit comme le succès. Nothing succeeds like success. > Was ...
- Java字段初始化的规律
class InitializeBookClass { { field=200; } public int field=100; public InitializeBookClass(int valu ...
- html部分---样式属性;
<!--大小--> width:宽度 height:高度 <!--背景与前景--> "background-color:#0F0; 背景颜色 background-i ...
- Codeforces Round #104 (Div. 1)
A.Lucky Conversion 题意 给定两个长度为 \(N(N \le 10^5)\) 且由4和7构成的 \(a, b\)串 对 \(a\) 可以有两种操作: 交换两个位置的字符; 改变一个位 ...
- php文件遍历
<?php $dirname="shangchuan/uploads"; echo $dirname."共计大小为:".toSize(dirsize($d ...
- Andoid 利用ndk-stack定位崩溃代码
Android NDK自从版本R6开始, 提供了一个工具ndk-stack( 在目录{ndk_root}/中 ). 这个工具能自动分析dump下来的crash log, 将崩溃时的调用内存地址和c++ ...