Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Shell test statements: integer comparison operators

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

-is eq equal to

-whether ne is not equal to

-whether the gt is greater than

-whether the lt is less than

-whether le is equal to or less than

-whether ge is equal to or greater than

Equal to (equal) larger (greater than) less-than (less than)

[root@master1-192,168117-18] # [10-gt 20]

[root@master1-192,168117-18] # echo $?

one

[root@master1-192,168117-18] # [40-gt 20]

[root@master1-192,168117-18] # echo $?

0

[root@master1-192,168,117-18 ~] # FreeMem=free-h | grep Mem: | awk'{print $4}'

[root@master1-192,168117-18] # echo $FreeMem

5.0G

Operator action

= compare whether the string content is the same

! = compare whether the string content is different

-z determine whether the content of the string is empty

[root@master1-192,168117-18] # [- z $String]

[root@master1-192,168117-18] # echo $?

0

[root@master1-192,168117-18] # [/ etc/hosts = / etc/profile]

[root@master1-192,168117-18] # echo $?

one

# [$LANG! = "en.US"] & & echo "Not en.US"

Not en.US

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report