当前位置:网站首页>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
边栏推荐
- 相机投影矩阵计算
- 权限模型 DAC ACL RBAC ABAC
- Pyqt common system events
- 小样本故障诊断 - 注意力机制代码 - BiGRU代码解析实现
- 2021-06-24: find the length of the longest non repeating character substring in a string.
- 12-- merge two ordered linked lists
- [acnoi2022] I have done it, but I can't
- The JS macro of WPS implements the separation method of picture text in the same paragraph
- 一文带你了解Windows操作系统安全,保护自己的电脑不受侵害
- Matlab求解线性方程组Ax=b
猜你喜欢
![[untitled]](/img/94/792e8363dbfe67770e93b0dcdc8e72.png)
[untitled]

WCF TCP protocol transmission

Question bank and simulation examination for operation certificate of refrigeration and air conditioning equipment in 2022

Understanding of the concept of "quality"

成为IEEE学生会员

问题3 — messageBox弹框,修改默认背景色

ZUCC_ Principles of compiling language and compilation_ Experiment 03 getting started with compiler

PAT 1157:校庆

LabVIEW finds prime numbers in an array of n elements
![Fundamentals of 3D mathematics [17] inverse square theorem](/img/59/bef931d96883288766fc94e38e0ace.png)
Fundamentals of 3D mathematics [17] inverse square theorem
随机推荐
Qt导出PDF文件的两种方法
Several ways you can't move zero (sequel)
5 minutes, excellent customer service chat handling skills
AUTO PWN
Tool functions – get all files in the project folder
Robot acceleration level task priority inverse kinematics
Getting started with ffmpeg
487. 最大连续1的个数 II ●●
Paper notes: multi label learning dm2l
The reason why the qtimer timer does not work
Question 3 - MessageBox pop-up box, modify the default background color
JUC个人简单笔记
App Startup
Maya re deployment
Understanding of the concept of "quality"
Opencv实现图像的基本变换
Markdown to realize text link jump
分布式 | 如何与 DBLE 进行“秘密通话”
新准则金融资产三分类:AMC、FVOCI和FVTPL
Promise usage scenarios