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

One of my Shell study notes & quot;expr"

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

**************************************

Bash mathematical operations expr:

Syntax:

expr $num1 operator $num2

expr Available operators (operator):

#When comparing variables with expr command, return 1 if true, return 0 if false, different from shell command line, return 0 if true, return non-0 if false.

num1 |num2 #num1 is not empty and non-zero, returns num1, otherwise returns num2

num1 & num2 #num1 is not empty and not 0, return num1, otherwise return 0

num1

< num2 #num1= num2 #num1>

=num2, returns 1, otherwise returns 0

+, -, *, /, %, **

When expr is used in SHELL Syntax:

expr $num1 \| $ num2

expr $num1 \& $num2

expr $num1 \

< $num2 expr $num1 \>

$num2

expr $num1 \>= $num2

expr $num1 \ $num2

0

[root@test ~]#

[root@test ~]# expr $num1 + $num2

22

[root@test ~]#

**************************************

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