shell编程——循环语句
来源:互联网 发布:淘宝售后工作职责 编辑:程序博客网 时间:2024/05/18 07:26
=====================================while语句========================================
while语句格式
while
i=1
while [ $i -lt 10 ]
do
sed -n "${i}p" 111.txt
i=$(($i+1))
done
while command
pause函数,输入任何值继续,输入q退出程序
pause()
{
while echo "Press <return> to proceed or type q to quit:"
do
read cmd
case $cmd in
esac
done
break———— 用来跳出循环
continue—— 用来不执行余下的部分,直接跳到下一个循环
===========================================FOR语句===================================
for
[root@mac-home home]# vi test.sh
:
echo "input num:"
read num
echo "input is $num"
num=$($num+1)
echo "new num is $num"
[root@mac-home home]# sh test.sh
input num:
3
input is 3
test.sh: line 6: 3+1: command not found
new num is[root@mac-home home]# vi test.sh
:
echo "input num:"
read num
echo "input is $num"
num=$(($num+1))
echo "new num is $num"
[root@mac-home home]# sh test.sh
input num:
3
input is 3
new num is 4
echo input:
read i
i=$(($i+1))
echo $i
read i
i=$[$i+1]
echo $i[macg@localhost ~]$ sh ttt.sh
input:
6
7[macg@localhost ~]$ sh ttt.sh
input:
6
7
if (( $# != 3 )); then
fiif [ $# != 3 ]; then
fi[macg@localhost ~]$ sh ttt.sh 1 2
usage: ttt.sh host user passwd[macg@localhost ~]$ sh ttt.sh 1 2
usage: ttt.sh host user passwd
给变量赋值,左边的变量不需要加 $ 符号,
foo=$(($foo+1))
赋值=,read,export都不需要加变量$
- shell编程——循环语句
- shell编程——循环语句
- shell编程——循环语句
- Shell脚本编程——(不用判断循环语句)
- shell编程之循环语句
- shell编程-循环语句
- shell编程—if语句
- linux C笔记4——Shell编程之循环语句
- Shell 编程6(循环语句for)
- Shell 编程7(循环语句while)
- Shell 编程8(循环语句until)
- shell编程之循环与判断语句
- shell 脚本编程之循环语句
- shell脚本编程之循环语句
- Shell编程第十一弹——循环
- shell 编程——for in 循环
- shell 编程——for in 循环
- shell 编程——for in 循环
- OpenStack对象存储-swift
- c语言版数据结构(奇迹冬瓜)-链表实战(2)合并两有序线性表
- 将代码以Eval方式加密、解密
- 常用的Double保留N位小数的转换
- RemoteViews的使用
- shell编程——循环语句
- JAVA序列化与反序列化三种格式存取(默认格式、XML格式、JSON格式)
- SPOJ 1182. Sorted bit squence (数位统计+二分)
- shell 编程——for in 循环
- 我对linux理解之framebuffer
- C++笔记(三)重载操作符
- MySQL Partition扫盲
- Shell 函数
- 卜算子之BIOS&&DOS中断向量表