当前位置:网站首页>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
边栏推荐
- JS merge multiple objects and remove duplicates
- Tencent cloud ASR product PHP realizes real-time voice authentication request
- 12-- merge two ordered linked lists
- 【无标题】
- 根据网络上的视频的m3u8文件通过ffmpeg进行合成视频
- ZUCC_ Principles of compiling language and compilation_ Big job
- Several ways you can't move zero (sequel)
- 单目双视三维坐标确定
- Building a static website with eleventy
- Review SGI STL secondary space configurator (internal storage pool) | notes for personal use
猜你喜欢

The article takes you to understand the security of Windows operating system and protect your computer from infringement

Question 3 - MessageBox pop-up box, modify the default background color

中国芯片独角兽公司

RCNN、Fast-RCNN、Faster-RCNN介绍

根据网络上的视频的m3u8文件通过ffmpeg进行合成视频

ZUCC_编译语言原理与编译_实验06 07 语法分析 LL 分析

成为IEEE学生会员

12-- merge two ordered linked lists

Longhorn installation and use

ZUCC_ Principles of compiling language and compilation_ Experiment 05 regular expression, finite automata, lexical analysis
随机推荐
05 Ubuntu installing mysql8
Final review and key points of software process and project management
Redis的Cluster集群数据倾斜
Nodejs redlock notes
The reason why the qtimer timer does not work
Scénarios d'utilisation de la promesse
Opencv实现图像的基本变换
ZUCC_ Principles of compiling language and compilation_ Experiment 05 regular expression, finite automata, lexical analysis
Easycvr invokes the interface parameter acquisition method and precautions of device video recording on the page
2021-03-11 comp9021 class 8 notes
Cloudbase database migration scheme
ZUCC_编译语言原理与编译_大作业
贷款五级分类
[real estate opening online house selection, WiFi coverage temporary network] 500 people are connected to WiFi at the same time
小样本故障诊断 - 注意力机制代码 - BiGRU代码解析实现
487. 最大连续1的个数 II ●●
Qt导出PDF文件的两种方法
Catégorie de prêt 5
LabVIEW finds prime numbers in an array of n elements
小黑ai4code代码baseline啃食1