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

The usage of linux shell (()) double bracket operator

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

Share

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

This article introduces the knowledge of "the use of linux shell () double parenthesis operator". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

How to use it:

Syntax:

(expression 1, expression 2... ))

Features:

1. In the double parenthesis structure, all expressions can be like the c language, such as: axioms, expressions, etc.

2. In the double parenthesis structure, all variables can not be prefixed with the "$" symbol.

3. Double parentheses can be used for logical operation and four operations

4. The double parenthesis structure extends the for,while,if conditional test operation.

5. Support multiple expression operations, which are separated by ","

Examples of use:

Extended four operations

The code is as follows:

#! / bin/sh

Axi1

Bread2

Cedar 3

((a=a+1))

Echo $a

Axiom $((axi1rementhmum)

Echo $a _

Running result:

Sh testsh.sh

two

3,3,4

Multiple expressions are supported between double parenthesis structures, and then common c language operators such as addition, subtraction, multiplication and division are supported. If the double parentheses are marked with: $, you will get the expression value and assign it to the left variable.

Extended logic operation

The code is as follows:

#! / bin/sh

Axi1

B = "ab"

Echo $(a > 1x 8vl 9)

((baked = "a")) & & echo "err2"

(a)

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