当前位置:网站首页>Shell basic operators -- relational operators
Shell basic operators -- relational operators
2022-06-24 08:37:00 【Chen Bucheng I】
Relational operator
Relational operators only support numbers , String not supported , Unless the value of the string is a number . The following table lists the common relational operators , Assumed variable a by 10, Variable b by 20
Operator | explain | give an example |
|---|---|---|
-eq | Check whether two numbers are equal , Equal return true. | [ $a -eq $b ] return false. |
-ne | Check if two numbers are not equal , Unequal return true. | [ $a -ne $b ] return true. |
-gt | Check whether the number on the left is greater than that on the right , If it is , Then return to true. | [ $a -gt $b ] return false. |
-lt | Check if the number on the left is less than the number on the right , If it is , Then return to true. | [ $a -lt $b ] return true. |
-ge | Check whether the number on the left is equal to or greater than the number on the right , If it is , Then return to true. | [ $a -ge $b ] return false. |
-le | Check whether the number on the left is less than or equal to the number on the right , If it is , Then return to true. | [ $a -le $b ] return true. |
Examples of relational operators are as follows :
#!/bin/basha=10b=20if[ $a -eq $b ]thenecho "$a -eq $b : a be equal to b"elseecho "$a -eq $b: a It's not equal to b"fiif[ $a -ne $b ]thenecho "$a -ne $b: a It's not equal to b"elseecho "$a -ne $b : a be equal to b"fiif[ $a -gt $b ]thenecho "$a -gt $b: a Greater than b"elseecho "$a -gt $b: a No more than b"fiif[ $a -lt $b ]thenecho "$a -lt $b: a Less than b"elseecho "$a -lt $b: a Not less than b"fiif[ $a -ge $b ]thenecho "$a -ge $b: a Greater than or equal to b"elseecho "$a -ge $b: a Less than b"fiif[ $a -le $b ]thenecho "$a -le $b: a Less than or equal to b"elseecho "$a -le $b: a Greater than b"fi
Execute the script , The output is as follows :
10-eq 20: a It's not equal to b10-ne 20: a It's not equal to b10-gt 20: a No more than b10-lt 20: a Less than b10-ge 20: a Less than b10-le 20: a Less than or equal to b
边栏推荐
- DHCP, TFTP Foundation
- Pyqt common system events
- ZUCC_ Principles of compiling language and compilation_ Big job
- Matlab求解线性方程组Ax=b
- orb slam build bug: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv‘
- ZUCC_编译语言原理与编译_实验05 正则表达式、有限自动机、词法分析
- 【毕业季】你好陌生人,这是一封粉色信笺
- Easycvr invokes the interface parameter acquisition method and precautions of device video recording on the page
- JUC personal simple notes
- 问题3 — messageBox弹框,修改默认背景色
猜你喜欢

【微服务~Nacos】Nacos服务提供者和服务消费者

小黑ai4code代码baseline啃食1

2022 tea artist (intermediate) work license question bank and online simulation examination

ZUCC_ Principles of compiling language and compilation_ Experiment 08 parsing LR parsing

jwt(json web token)
![Fundamentals of 3D mathematics [17] inverse square theorem](/img/59/bef931d96883288766fc94e38e0ace.png)
Fundamentals of 3D mathematics [17] inverse square theorem

Qt导出PDF文件的两种方法

MAYA重新拓布

李白最经典的20首诗排行榜
![[untitled]](/img/94/792e8363dbfe67770e93b0dcdc8e72.png)
[untitled]
随机推荐
日本大阪大学万伟伟研究员介绍基于WRS系统机器人的快速集成方法和应用
Easycvr invokes the interface parameter acquisition method and precautions of device video recording on the page
2021-03-04 comp9021 class 6 notes
05 Ubuntu installing mysql8
独立站运营中如何提升客户留存率?客户细分很重要!
pyQt 常用系统的事件
复习SGI STL二级空间配置器(内存池) | 笔记自用
问题3 — messageBox弹框,修改默认背景色
分布式 | 如何与 DBLE 进行“秘密通话”
The article takes you to understand the security of Windows operating system and protect your computer from infringement
相机投影矩阵计算
常用日期格式符与Qt获取当前时间的办法
Catégorie de prêt 5
Opencv get (propid) common values
Question bank and simulation examination for operation certificate of refrigeration and air conditioning equipment in 2022
orb slam build bug: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv‘
2021-03-16 comp9021 class 9 notes
小黑ai4code代码baseline啃食1
ZUCC_编译语言原理与编译_实验01 语言分析与简介
Use cpulimit to free up your CPU