the parentheses are the orders. curly braces are variable valuesOne, parenthesis, parentheses ()1 , single parenthesis ()① Command Group. The commands in parentheses will be executed in a new sub-shell sequence, so the variables in parentheses
One, parenthesis, round brackets () 1, single parenthesis () ① command group. The commands in parentheses will be executed in a new sub-shell sequence, so the variables in parentheses cannot be used by the rest of the script. Multiple commands in
Tips Summary:String comparison with double brackets [[]]; arithmetic comparison with single brackets []--left and right spacesArithmetic operations with double parentheses (()); Shell commands and output parentheses ()--left and right without
[[email protected] log]# var=/dir1/dir2/file.txt1, variable value [[email protected] log]# Echo ${var}/dir1/dir2/ File.txt2 the length of the string [[email protected] log]# echo ${#var}193, extract position 3 to the last character [[email protected]
Reprinted from Nxhujiee final edit lj_suntb batch processing "preprocessing"━━━━━━━━━━━━━━━━━━━━━━━━━━If you are familiar with the processing mechanism of the caret character "^" then you can read it, noPlease refer to the relevant articles of the
String interception of Linux is useful. There are eight ways.Suppose there is a variable var=http://www.aaa.com/123.htm.1. # Intercept, delete the left character, leave the right character.echo ${var#*//}where Var is the variable name and the # is
One, parenthesis, parentheses ()1, single parenthesis ()① Command Group. The commands in parentheses will be executed in a new sub-shell sequence, so the variables in parentheses cannot be used by the rest of the script. Multiple commands in
One, parenthesis, parentheses ()1, single parenthesis ()① Command group . The commands in parentheses will be executed in a new sub-shell sequence, so the variables in parentheses cannot be used by the rest of the script. Multiple commands in
1. Replace the variable $ {varname:-word}. If the variable varname exists and is not null, its value is returned. Otherwise, word is returned.
$ {Varname-word} if the variable varname exists, its value is returned. Otherwise, word is returned.
1. Examples of error methods
A
Var=1+1
Echo $var
The result of the output is 1+1, tragedy, hehe
b
Var=1
var= $var +1
Echo $var
The output result is 1+1, still tragic, hehe
2. The correct method
1) using Let
Var=1
Let "Var+=1"
Echo $var
The output
Shell commands are generally divided into built-in (self-contained) and exotic (except those that come with the Yum installation later)How to produce a built-in command: $ man Bash 1 (why add a 1 here because of the manual format)The composition of
1.1 IntroductionThe shell is a C language scripting language, it is the user and Linux bridge, the user input command to the shell processing, the shell will be the corresponding operation to the kernel (Kernel), the kernel to the results of
See if the script syntax has errors:Bash-n modify_suffix.shTrack executionSh-x modify_suffix.sh AAA1.${var} 2.$ (cmd) 3. () and {} 4.${var:-string},${var:+string},${var:=string},${var:?string} 5.$ ((exp)) 6.$ (Var%pattern), $ (var%%pattern), $
Shellprogramming review notes-variables, environment variables, and quotation mark variables can be roughly divided into four categories: local variables, environment variables, location variables, and special variables. The two are read-only
Reprinted from nxhujiee to final edit [preprocessing] In LJ_SunTB Batch Processing]When there are too many threads, there are too many threads, too many threads.
If you are familiar with the processing mechanism of the delimiters "^", you can
Shell programming review notes-variables, environments, and quotation mark variables can be roughly divided into four categories: local variables, environment variables, location variables, and special variables. The latter two are read-only
Array: A contiguous memory space that stores multiple elements, equivalent to a collection of multiple variables1) define the array:Declare-a Array_Name defines an ordinary array can be omitted declare-a] #arr = (a b c D E F)Declare-a Array_Name
The previous section explains why referencing variables with ${}, ${} also has an important function, that is, text processing, a single line of text can basically meet all your needs.3.1 Get string length# var= ' Hello world! ' # echo $VARhello
The first method: #%*, #即截取变量前的字符 (intercept left to right),% means intercept trailing character (right-to-left intercept), * match character var=foodforthought.jpg${varible##*string} A string that intercepts the last string from left to right runs:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.