博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux shell program summary
阅读量:4356 次
发布时间:2019-06-07

本文共 1582 字,大约阅读时间需要 5 分钟。

from:Sep 23 2016


 

mathematical operation:

floating number,bc calculator:

we can also use bc in shell scripts:


 

if - then - else

number comparison:

              n1 -eq n2

              n1 -ge n2

              n1 -gt n2

              n1 -le n2

              n1 -lt n2

              n1 -ne n2

if - then - elif, notice that the second elif won't be executed, though it's also right.


 

strings comarison:

                          str1 = str2

                          str1 != str2

                          str1 < str2

                          str1 /> str2

                          -n str1

                          -z str1


 using file comparisons:

                  -d file    checks if file exists and is a dictory

                       -e file    checks if file exists

                       -f file     checks if file exists and is a file

                       -r file     checks if file exists and is readable

                  -s file     checks if file exists and is not empty

                       -w file    checks if file exists and is writable

                       -x file     checks if file exists and is executable

                       -o file     checks if file exists and is owned by the current user

                       -G file    checks if file exists and the default group is the same as the current user

                        file1 -nt file2   checks if file1 is newer than file2

                        file1 -ot file2   checks if file1 is older than file2


 considering compound testing


 

working with advanced if-then features

          ((expression))

                   var++

                   var--

                   ++var

                  --var

                  !              logical negation

                 ~              bitwise negation

                 **             exponentiation

                 <<

                 >>

                 &

                 |

                 &&

                  ||

notice the '++' of the screenshot.

it's writen of var++ not $var++


using double brackets

          [[ expression ]]

 the double bracket command provides advanced features for string comparisons---pattern matching.


Considering the case command:

 

case variable in

pattern1 | pattern2) command1;;

pattern3) command2;;

*) default commands;;

esac


 The for command:


 

 The while command:


 

The until command:

 

转载于:https://www.cnblogs.com/rixiang/p/5901493.html

你可能感兴趣的文章
Kali Linux Web渗透测试手册(第二版) - 3.2 - 使用ZAP寻找敏感文件和目录
查看>>
Python入门 学习笔记 (一)
查看>>
ArrayList简单实现代码,欢迎大家指点
查看>>
Android开发手记(30) 触摸及手势操作
查看>>
Python------类的结构细分,异常处理,方法,属性
查看>>
41.内存函数实现(memcpy,memset,memmove,memicmp,memchr.memccpy)
查看>>
环形队列的c++实现
查看>>
扩展欧几里德算法求不定方程
查看>>
软件项目托管平台
查看>>
Oracle :多表更新多个字段
查看>>
Programming Languages - Coursera 整理
查看>>
ASP.NET MVC 3 入门级常用设置、技巧和报错
查看>>
硬件访问方法和混杂字符设备
查看>>
shell 脚本获取远程服务器信息并发送邮件
查看>>
基于Docker搭建MySQL主从复制
查看>>
两台centos之间传送文件
查看>>
使用DevExpress官方汉化文件对界面进行汉化的过程
查看>>
关于获取各种浏览器可见窗口大小的一点点研究
查看>>
C#获取枚举描述
查看>>
emwin 之模态窗口
查看>>