当前位置:网站首页>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
边栏推荐
- Tencent cloud ASR product PHP realizes real-time voice authentication request
- Several ways you can't move zero (sequel)
- orb slam build bug: undefined reference to symbol ‘_ZN5boost6system15system_categoryEv‘
- 貸款五級分類
- Understanding of the concept of "quality"
- 2021-06-24: find the length of the longest non repeating character substring in a string.
- "Adobe international certification" Photoshop software, about drawing tutorial?
- Rust procedure macro simply imitates Lombok function
- [xinliu-s6 new model +sa 3-star Xinghai] the new two-way server of the third generation chip was launched and the product was updated~
- JS merge multiple objects and remove duplicates
猜你喜欢

Markdown to realize text link jump

Introduction to RCNN, fast RCNN and fast RCNN

5 minutes, excellent customer service chat handling skills

问题4 — DatePicker日期选择器,2个日期选择器(开始、结束日期)的禁用

Maya re deployment

Pat 1157: school anniversary

Synthesize video through ffmpeg according to m3u8 file of video on the network

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

2022 tea artist (intermediate) work license question bank and online simulation examination
随机推荐
Live broadcast review | detailed explanation of koordinator architecture of cloud native hybrid system (complete ppt attached)
5分钟,客服聊天处理技巧,炉火纯青
复习SGI STL二级空间配置器(内存池) | 笔记自用
【力扣10天SQL入门】Day3
AUTO PWN
小样本故障诊断 - 注意力机制代码 - BiGRU代码解析实现
05-ubuntu安装mysql8
Review SGI STL secondary space configurator (internal storage pool) | notes for personal use
Permission model DAC ACL RBAC ABAC
Common date formatter and QT method for obtaining current time
【力扣10天SQL入门】Day2
一文带你了解Windows操作系统安全,保护自己的电脑不受侵害
List of Li Bai's 20 most classic poems
Redis cluster data skew
[untitled]
Detailed explanation of etcd backup and recovery principle and actual record of stepping on the pit
leetcode 1642. Furthest Building You Can Reach(能到达的最远的建筑)
Easydss anonymous live channel data volume instability optimization scheme sharing
[graduation season] Hello stranger, this is a pink letter
ZUCC_编译语言原理与编译_实验03 编译器入门