shell编程基础与进阶
shell编程
Test_Simon
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
shell-continue指令 & 循环输出的处理
shell-continue指令处理循环的输出 #!/bin/bash for ((i=1;i<=30;i++)) do if ((i>15 && i<25));then contiune else echo ”number is $i" fi done 处理循环的输出 #!/bin/bash for ((i=1;i<=100;i++))...原创 2020-04-29 14:38:45 · 537 阅读 · 2 评论 -
shell中的 跳出循环的break指令
shell中的break指令 #!/bin/bash for ((i=1;i<=10;i++)) do if ((i==5));then break else echo "$i" fi done # 5及其后边的数字都不会执行 #!/bin/bash for ((i=1;i<=10;i++)) do for ((j=1;j<=5;j++)) do if (...原创 2020-04-29 14:25:09 · 852 阅读 · 0 评论 -
shell-until命令使用
shell-until命令使用until命令的使用 until命令的使用 until直到后面的command满足条件时 停止执行 until command do commands done 直到num=0时停止执行。 #1/bin/bash num=10 until [ $num -eq 0 ] #until (( num==0 )) do echo "Number is $num" ...原创 2020-04-29 14:11:22 · 315 阅读 · 0 评论 -
shell-while循环命令
shell-while循环命令while循环语法 while循环语法 while command do commands done while不知循环次数时使用,例如 #1/bin/bash num=10 #while ((num<20)) while [ $num -ls 20 ] do echo "number is $num" (( num++ )) done ...原创 2020-04-29 14:04:37 · 398 阅读 · 0 评论 -
shell - for命令讲义
shell - for命令for命令简介for 循环读取列表值遍历列表遍历连续数字输出格式两位的01for循环读取变量的值for循环从命令执行结果中遍历值c语言分隔的for循环c语言的for循环shell中 for命令简介 循环遍历 for var in list do commands done list 可以是命令 eg: ll 列出文件名 for 循环读取列表值 遍历列表 #!/bin/...原创 2020-04-29 13:55:08 · 280 阅读 · 0 评论 -
shell-case命令的使用
shell-case命令的使用case语句的语法 if语句中存在如下逻辑处理 if ((a==1));then commands elif ((a==2));then commands elif ((a==5));then commands else commands fi case语句的语法 case $var in pattern1) commands ;; pat...原创 2020-04-29 13:04:45 · 363 阅读 · 1 评论 -
shell基础-if语句
shell基础-if语句简单if语句if-then-else语句的使用if嵌套语法 简单if语句 if command|condition then commands fi command的命令成功执行的话就可以进入then后边的逻辑语句。(依据退出状态码来判断是否要执行) if PWD then echo "it works" fi # PWD指令生效 就进行then后边的语句。 if...原创 2020-04-29 12:49:30 · 209 阅读 · 0 评论 -
shell-基础探讨。
shell-编程基础知识变量名遵循原则 变量名遵循原则原创 2020-04-29 10:48:01 · 211 阅读 · 0 评论 -
shell-数值比较
shell-数值比较条件测试-数值的比较 条件测试-数值的比较 数值的比较: -eq 相等(equal) -ne 不等(not equal) -gt 大于(greater than) -lt 小于(less than) -ge 大于等于 (greater than or equal) -le 小于等于 (less than or equal) ...原创 2020-04-23 15:55:31 · 492 阅读 · 0 评论 -
shell-条件判断-字符串比较
字符串比较字符串比较 字符串比较 参数 说明 == 相等则为真 != 不相等则为真 参数 说明 str1= str2 相等则为真 str1 != str2 不想等比较 str1< str2 str1 < str2为true str1> str2 str1 > str2为true -n str1 str长度不是0则为true -z s...原创 2020-04-24 15:50:19 · 1359 阅读 · 0 评论 -
shell-条件判断-文件比较
文件比较 比较 含义 -s file file存在且非空 file1 -nt file2 file1比file2新为true file1 -ot file2 管 file1比file2旧为true -r -x -d 对应的权限原创 2020-04-24 16:15:07 · 414 阅读 · 0 评论 -
shell-条件判断-复合条件测试
复合条件测试 && 与 || 或原创 2020-04-24 17:00:38 · 760 阅读 · 0 评论 -
shell--双括号
shell双括号的作用可用运算符号注意事项 使用双括号可以进行算数运算,可以写类C语言的运算表达式。 a++ 或者 b-- 或者a+=1 或者a<b 或者a!=b if-then语法 if condition then commands fi if [ -d file ] then commands fi if ((expression)) then commands fi 可用运算符号 ...原创 2020-04-24 17:42:41 · 974 阅读 · 0 评论 -
shell--双方括号
shell--双方括号 if [[ $n1 -gt $n2 && $n2 -lt $n3 ]] then commands fi if [[ $n1 > $n2 && $n2 < $n3 ]] then commands fi 双[[ ]] 中变量名必须加$ 括号旁边必须有空格 ...原创 2020-04-24 18:22:27 · 300 阅读 · 0 评论
分享