shell while的用法
1.
#!/bin/sh
int=1
while (( "$int < 10" ))
do
echo "$int"
let "int++"
done
2.
#!/bin/sh
sum=0
int=1
while (( "$int < 100" ))
do
let "sum+=int"
let "int+=2"
done
echo "the sum is $sum"
3.
#!/bin/sh
echo "please input the num(1-10)"
read num
while [[ "$num"!=4 ]]
do
if [ "$num" -lt 4 ]
then
echo "the num is too large,please input again"
read num
elif [ "$num" -gt 4 ]
then
echo "the num is too small,please input again"
read num
else
echo "right you are right"
exit 0
fi
done
echo "right you are right"
4.
#!/bin/sh
echo "please input the num"
read num
sum=1
while [ "$num" -gt 0 ]
do
let "sum=sum*num"
let "num--"
done
echo "the sum is $sum"
5.
#!/bin/sh
echo "please input the num(1-10)"
read num
signal=0
while [[ "$signal" != 1 ]]
do
if [ "$num" -lt 5 ]
then
echo "the num is too small,please try again"
read num
elif [ "$num" -gt 5 ]
then
echo "the num is too large please try again"
read num
else
echo "you are right"
let "signal=1"
fi
done
6.
#!/bin/sh
echo "the par num is $#"
echo "what you input is"
while [[ "$*" != "" ]]
do
echo "$1"
shift
done
shell while的用法的更多相关文章
- Shell expr的用法 bc 命令 let命令
Shell expr的用法 bc 命令 let命令 数学运算 let命令 expr命令 bc命令 $(()) $[] http://www.80ops.cn/archives/245. ...
- hbase基本概念和hbase shell常用命令用法
1. 简介 HBase是一个分布式的.面向列的开源数据库,源于google的一篇论文<bigtable:一个结构化数据的分布式存储系统>.HBase是Google Bigtable的开源实 ...
- 【转载】HBase基本概念和hbase shell常用命令用法
1. 简介 HBase是一个分布式的.面向列的开源数据库,源于google的一篇论文<bigtable:一个结构化数据的分布式存储系统>.HBase是Google Bigtable的开源实 ...
- shell字符串的用法
shell字符串的用法 注意:shell4.2和shell4.1会有差别,较低版本的shell可能不支持某些功能 获取字符串长度:${#string} 获取子串: 注:(左边的第一个字符是用 0 表示 ...
- centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课
centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件.目录属性 shell数组简单用法 $( ) 和$ ...
- (12)Linux shell之read 用法
Linux shell之read 用法 #!/bin/bash#read 用来读取屏幕输入或是读取文件内容.read -p "please input you name: " ...
- Shell之date用法
创建以当前时间为文件名的 mkdir `date+%Y%m%d` 备份以时间做为文件名的 tar cvf./htdocs`date +%Y%m%d`.tar ./* date命令如何获得上星期的日期? ...
- Linux Shell nohup命令用法
linux的nohup命令的用法. 在应用Unix/Linux时,我们一般想让某个程序在后台运行,于是我们将常会用 & 在程序结尾来让程序自动运行.比如我们要运行mysql在后台: /us ...
- shell特殊符号用法大全
# 注释符号(Hashmark[Comments]) 1.在shell文件的行首,作为shebang标记,#!/bin/bash; 2. 其他地方作为注释使用,在一行中,#后面的内容并不会被执行, ...
- linux shell date的用法
该随笔引用自https://www.cnblogs.com/alsodzy/p/8403870.html 在 linux shell 里面date命令的参数 %% 一个文字的 % %a 当前local ...
随机推荐
- PAT 天梯赛 L1-033. 出生年 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-033 AC代码 #include <cstdio> #include <cstring> ...
- 自己动手编译Android源码(超详细)
http://www.jianshu.com/p/367f0886e62b 在Android Studio代码调试一文中,简单的介绍了代码调试的一些技巧.现在我们来谈谈android源码编译的一些事. ...
- 【鸟哥的Linux私房菜】笔记
操作系统核心的功能! 驱动程序与操作系统的关系 2. [计算机组成之组件] 3.CPU实际要处理的数据完全来自于主存储器,这是一个很重要的概念! 4.CPU是整个计算机系统最重要的部分,那么目前世界上 ...
- CentOS 6.5 下的截图方法
1.利用命令模式 捕获整个屏幕 : $ gnome-screenshot 截完屏之后我们可以设置自定义图片存储位置,如图: 捕获当前终端Terminal : $ gnome-screenshot -w ...
- Go 文件操作
一.读取文件 普通版 ioutil版 bufio版 二.文件写入 普通版 ioutil版 bufio版 三.文件复制 ioCopy 1.普通版读取文件 package main import ( &q ...
- Go panic recover
panic 1. 停止当前函数执行 2. 一直向上返回,执行每一层的defer 3. 如果没有遇到recover, 程序退出 recover 1. 仅在defer调用中使用 2. 获取panic的值 ...
- ActiveMQ部署和503的错误
最近部署ActiveMQ的时候,发现有的服务器可以打开后台管理网址,有的服务器无法打开,Jetty报503 Service Unavailable. 搞了很久终于发现了问题,现将部署和解决过程做笔记如 ...
- 和BEM的战斗:10个常见问题及如何避免
原文链接: https://segmentfault.com/a/1190000006135647 无论你是刚刚发现BEM或者已经是个中熟手(作为web术语来说),你可能已经意识到它是一种有用的方法. ...
- UVA 1638 Pole Arrangement (dp)
题意:有n个长度为1到n的柱子排列在一起,从左边看有l根从右边看有r根,问你所以排列中满足这种情况的方案数 题解:就是一个dp问题,关键是下标放什么,值代表什么 使用三维dp,dp[i][j][k]= ...
- php+JS进度条
<?phpini_set('max_execution_time','0');//设置本页面加载时间无限制 echo "<div style='border: 1px solid ...