37. Adjust the properties of a variable
Read-only variable: use the readonly command
ReadOnly variable Name
ReadOnly Other uses
ReadOnly or readonly-p: Displays a list of variables that currently have read-only properties
readonly-f function Name: Set the function cannot be modified
READONLY-A array Variable: Set-a followed by the variable name is a read-only array
Read-only variable: using declare
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/6F/wKioL1TTCW3xIhENAAM0t-edeCE595.jpg "title=" 1.PNG " alt= "Wkiol1ttcw3xihenaam0t-edece595.jpg"/>
38. Custom Environment Variables
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/6F/wKioL1TTC0vAbG9vAADceDIwE4g923.jpg "title=" 3.PNG " alt= "Wkiol1ttc0vabg9vaadcediwe4g923.jpg"/>
39.Here Document
Basic usage:
[[email protected] ~]# cat >>123.txt<< end> Hello > My name is ' Jack ' > Welcome to bj> Endyou has New mail In/var/spool/mail/root[[email protected] ~]# cat 123.txt Hello my name is "Jack" Welcome to BJ
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/6F/wKioL1TTE92yLp0NAACk8q-GaiE255.jpg "title=" 4.PNG " alt= "Wkiol1tte92ylp0naack8q-gaie255.jpg"/>
[Email protected] ~]# wow= ' wow,great! ' [Email protected] ~]# m1=$ (cat <<HERE> Line 1 was good.> they are jack,marry and john.> $WoW > Here>) [Email protected] ~]# echo $m 1line 1 is good. They is Jack,marry and John.
[Email protected] ~]# m1=$ (cat << "Here" > Line 1 is good.> they be jack,marry and john.> $WoW > here> ) [[email protected] ~]# echo $m 1line 1 is good. They is Jack,marry and John. $WoW
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/73/wKiom1TTFjOwmdmpAADrNum83yA469.jpg "title=" 5.PNG " alt= "Wkiom1ttfjowmdmpaadrnum83ya469.jpg"/>
40. How to test if a variable exists
Syntax: ${variables to be tested-default value}
Explanation: To determine whether the variable being tested exists, if the variable exists, it returns the value of the variable, if not it will pass the default value to the variables to be tested
[[email protected] ~]# unset myname[[email protected] ~]# r=${myname-' basher '}[[email protected] ~]# echo $rbasher
[Email protected] ~]# myname= "Jack" [[email protected] ~]# r=${myname-' basher '}[[email protected] ~]# echo $rJack
[[email protected] ~]# myname=[[email protected] ~]# r=${myname:-' basher '}[[email protected] ~]# echo $rbasher [[Email Pro Tected] ~]# unset myname[[email protected] ~]# r=${myname:-' basher '}[[email protected] ~]# echo $rbasher
Use if to judge
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/73/wKiom1TTHCOCpQAYAABP65J52yw063.jpg "title=" 6.PNG " alt= "Wkiom1tthcocpqayaabp65j52yw063.jpg"/>
Test whether the variable "does not exist" or its value is empty: Prompt for error message
Syntax: ${variables to be tested:? Prompt message}
Explanation: Determine whether the variable "does not exist" or "empty", if the condition is true, then display: after the prompt message. and immediately stop executing the script
To disassemble an expression:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/74/wKiom1TTIDPiB-7bAAEcm389dZM027.jpg "title=" 7.PNG " alt= "Wkiom1ttidpib-7baaecm389dzm027.jpg"/>
Example:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/74/wKiom1TTIMjgt_e1AAEZHBPM6qQ329.jpg "title=" 8.PNG " alt= "Wkiom1ttimjgt_e1aaezhbpm6qq329.jpg"/>
This article is from the "Linux Revolution" blog, so be sure to keep this source http://kaibinyuan.blog.51cto.com/7304008/1612017
Shell theory Study (iii)