1, the length of the characters in the variable: ${#VARNAME}
#A = ' Hello World '
#echo ${#A}--Displays the length of the defined variable A, with an output of 11
#11
2, variable assignment value, etc.:
${parameter:-word}: If parameter is empty or undefined, the variable expands to "word"; otherwise, expands to the parameter value;
${parameter:+word}: If parameter is empty or undefined, do nothing, otherwise expand to Word value;
${parameter:=word}: If parameter is empty or undefined, the variable expands to "word" and assigns the expanded value to parameter;
${parameter:offset}: Remove the defined offset number
${parameter:offset:length}: Takes a substring, starts at the last character at the offset, and takes the lenth long substring
--------------------------------------------------------
The most commonly used is the first, such as:
${parameter:-word}
#A =3
#echo ${a:-30}---indicates that the variable A is not empty, the expression uses the value of the variable itself
#3
#unset A
#echo ${a:-30}---indicates that the variable A is empty, the expression uses its own value
#30
#A =${a:-30}---indicates that variable A is empty, it is assigned to the variable a with its own value
#echo $A---to indicate that the variable A is not empty, it is assigned to the variable a again using the value of variable a
#30
${parameter:+word}
#A =3
#echo ${a:+30}---indicates that the value of Word is used when variable A is not empty
#3
#unset A
#echo ${a:+30}---indicates that the variable A is empty and the value is null
#为空
${parameter:=word}
#unset A
#echo ${a:=30}--Indicates that the variable a is empty, not only expands the expression to this string, but assigns the string value to a
#30
${parameter:offset}
#A = ' Hello World '---define a variable
#echo ${a:2}---Number 2 indicates that the string in variable A is offset 2 from left to right, showing everything from the offset
#llo World
${parameter:offset:length}
#echo ${a:2:3}---Number 2 indicates that the string in variable A is offset from left to right 2, and the number 3 indicates that 3 characters are taken from the offset position
#llo
-----------------------------------------------------------