Shell练习-2(控制语句,if else,for,while)
来源:互联网 发布:网络问政是什么意思 编辑:程序博客网 时间:2024/05/29 04:23
#!/bin/shecho "hello"filePath=`pwd`echo "path:${filePath}"a=10b=20echo '--------------if else练习-------------------'if [ $a -lt $b ]then echo "a小于b"else echo "没有符合的条件"fiecho '-------------if else if else练习--------------------'#注意,if条件中前后都得有空格if [ $a == $b ]then echo "a等于b"elif [ $a -gt $b ]then echo "a大于b"else echo "没有符合的条件"fi#结合test使用if test $a -lt $bthen echo "a大于b"else echo "没有符合的条件"fiecho '----------------if字符串比较-----------------'#在shell脚本里面,字符串表示,加引号和不加引号,效果是一样的; 我们试一下v1="true"v2=trueif [ $v1 == $v2 ] #这里注意表达式前后空格,错一个都不行; 这里不能用 -eq, 要用==then echo "是true"else echo "不知道是啥"fiecho '----------------for循环练习-----------------'for item in java c# javascript c++ c;do #记住:单引号里面不能使用变量,如:'$item', 可以用双引号或者不用引号,直接写 echo "${item}"doneecho '----------------for循环一个数组-----------------'arr=(中国 美国 法国 韩国)for item in ${arr[*]}do echo "$item"done;for item in this is a string;do echo -e "$item"doneecho '----------------while循环练习-----------------'int=1#注意: 条件中的前后空格while (( $int <= 5 ))do echo $int let int++done
0 0
- Shell练习-2(控制语句,if else,for,while)
- Shell中的if else语句 while语句
- JS:1.2控制语句(if,if else,for,switch,while,do while)
- 循环语句if(){}else{}、if(){}else if(){}...else{}、do{}while()、for(){}、with(){}break/continue语句
- Oracle中的几种控制语句if..else,for,loop,while
- if-else 语句练习
- shell 语句 if for while until case
- awk 控制语句(if for do while)
- Oracle控制语句(if , loop , while , for)
- Oracle控制语句(if , loop , while , for)
- Oracle控制语句(if , loop , while , for)
- python控制流语句-while,for,if
- Oracle控制语句(if , loop , while , for)
- Oracle控制语句(if , loop , while , for)
- Shell if else语句
- Shell if else语句
- Shell if else语句
- Shell if else语句
- JAVA之输出一个四位整数的各位数字之和
- MAVEN项目标准目录结构
- 常用正则表达式大全
- 使用android访问SQLServer数据库
- 什么是 TensorFlow?
- Shell练习-2(控制语句,if else,for,while)
- What does '???' (three question marks) mean in Scala?
- 网络图片获取原理
- org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component c
- SVN使用教程总结
- 【Dongle】【Java】规范之JMS
- css/css3总结(二)属性
- Liunx 学习之chmod,chown,chgrp命令
- javascript基础:String对象