In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
First of all, we need to understand the content and format of the script
The first line must be shebang (interpreter path), and shebang must be the absolute beginning of the line.
In shell scripts, except for shebang, the content at the beginning of a data pair with # is a comment line, and the interpreter automatically ignores such line content.
In order to highlight the function of the program, add blank lines appropriately to separate different source code blocks
There is a certain indentation
Use bash script programming to realize arithmetic operation:
+,-
*, /
%: modular operation, take remainder
* * | ^
Enhanced arithmetic symbol
+ =: let Bond 2muri-> let Bamboo 2
-= let baked 2murf-> let Blichy 2
* = let Bond 2 color-> let Bond 2
/ = let Bond 2 color-> let Banner 2
% = let Bond Bond 2muri-> let B% copyright 2
Special enhanced operations:
Let B=B+1-- > let Barrier 1-- > let Barrier +
Let B=B-1-- > let Bmuri 1-- > let Bmuri--
Bounded variables: first assign the value of B to other variables, and then itself + 1
+ B: do your own + 1 calculation first, and then assign the value of B to other variables
The arithmetic operation method provided by shell
1.let:let VAR= arithmetic expression
The arithmetic expression is calculated in advance, and the moral result of the operation is saved to the variable VAR.
2. VARTED $[arithmetic expression]
In arithmetic expressions, if there is a variable reference, you can use a $reference or omit $
3. VARTED $((arithmetic expression))
In arithmetic expressions, if there is a variable reference, you can use a $reference or omit $
4.expr ARGU1 ARGU2 ARGU3
ARGU1 and ARGU3 must be numeric, and ARGU2 must be an operation symbol
5.echo "arithmetic expression" | bc
Note: * escape is required in some cases
Conditional test command
Test EXPRESSION
Built-in commands for shell
[EXPRESSION]
External command [external command]
`EXPRESSION`
Internal keywords of bash
Note: this kind of command generally has no execution result, only the return value of execution status.
Here's the test expression for the test test command.
There are three types of test expressions for test test commands:
1. Numeric testing: Binocular operator
-eq: whether the two values tested are equal, true or false
-ne: whether the two values tested are not equal, true or false
-gt: whether the value on the left is larger than that on the right, whether it is true, and not greater than if it is false.
-lt: whether the left value is smaller than the right value, less than true, and not less than false
-ge: whether the left value is greater than or equal to the right value, greater than or equal to true, and less than is false
-le: whether the two values tested are less than or equal to the right, less than or equal to true, and greater than false
two。 String test
Binocular operator:
= = | =: whether the two strings tested are the same, the same is true, and the difference is false
! =: whether the two strings tested are different, the difference is true, and the same is false
>: the corresponding binary values of the two strings tested in the ASCII code table, whether the left is greater than the right, greater than true, less than false
And
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.