Tag: blank target Context string
The definition of a variable: simply by letting a particular string represent something that is not fixed.
Categories of variables:
Environment variables: scoped to the current shell process and its child processes
Local variables: scoped to the current shell process
Local variables: scoped only to a snippet of code in the current shell process (usually a function context)
Positional variables:
Special variables:
Access to variables: Echo
As shown, the variable is used just by using echo and then adding a $ to the variable name.
Setting and modifying variables: variables = variable contents
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/D0/wKiom1XtkpjTFVIaAACRJGv92uk130.jpg "/>
Setting rules for variables:
- Variable and variable contents are connected by an equal sign
- Cannot directly connect whitespace on both sides of equal sign
- Variable names can only be English letters and numbers, but cannot begin with numbers
- Variable contents If there is a space, you can use double quotation marks or single quotation marks to cause the contents of the variable
Double quotation marks are weak references, such as special characters in double quotation marks can keep their original particularity
Single quotes are strong references, where special characters are only ordinary characters
- You can escape a special word to a generic character by escaping the backslash \ Character
- In a sequence of instructions, you can use the inverted single quotation mark ["] or [$ ()] to refer to other directives.
- You can append content with variable = "$ variable name" or variable =$ (variable)
- To execute in Bash's subroutine, you need to use export to define the environment variable
- To cancel the use of a variable unset variable name
View of variables (evn,export,set)
EVN: View environment variables and descriptions
Export: Same as EVN, but can also customize variables as environment variables
Set: You can view not only the environment variables but also the custom variables
Common environment variables:
Home: Represents the user's home directory
Shell: The shell used by the representative
Histsize: How many records can be stored on behalf of
Mail: Represents the path where the mailbox is stored
Path: Represents the storage path of the execution file
LANG: The language used by the representative
Random: Take the stochastic number (0-32767)
$: PID representing the current shell
?: Feedback on success of last instruction execution
0: Success for execution
1-255: failed for execution
PS1: Command Prompt settings
\d: Date format showing "Day of the Week"
\h: Full host name
\h: Takes the first name of the hostname before the decimal point
\ t: Time displayed as 24-hour format [HH:MM:SS]
\ t: Time displayed as 12-hour format [HH:MM:SS]
\a: Show time in 24-hour format [hh:mm]
\@: Show time in 12-hour format [hh:mm]
\u: Displays the account name currently in use
\V: Show version information for bash
\w: Displays the full working directory name
\w: Displays the base name of the working directory
\#: Shows the release of the first few instructions
\$: Display prompt
Bash Environment configuration:
Global configuration:
/etc/profile
/etc/profile.d/*.sh
/etc/bashrc
Personal configuration:
~/.bash_profile
~/.bashrc
Environment variables under bash