"\[enter]" "Jump off
Access to variables: Echo
Echo $HOME
Myname=vbird
Echo $myname
Setting rules for variables
1, variable and variable contents with = To connect Myname=vbird
2, no spaces on either side of the equals sign
3, variable names can only be English letters and numbers, but cannot start with numbers
4, variable contents have spaces with "or" to combine the contents of variables, but,
The special characters within the double quotation mark such as $ etc., can retain the original characteristics, as follows:
"var=" Lang is $LANG "" Then "echo $var" can get "Lang is en_US"
The special characters in single quotation marks are only ordinary characters (plain text), as follows:
"Var= ' Lang is $LANG '" then "Echo $var" to "Lang is $LANG"
5. Use the caret character "\" To turn special symbols (such as [Enter], $, \, space, ' etc.) into general characters;
6. In a series of instructions, you also need to provide information by other instructions, you can use the anti-single quotation mark "' instruction '" or "$ (directive)".
In particular, that ' is the number key above the keyboard 1 the left button, not the single quote! For example, to get the core version of the settings:
"Version=$ (Uname-r)" and "Echo $version" can get "2.6.18-128.el5"
7. If the variable is the content of the amplified variable, you can use the "$ Send Name" ring ${Volume} to accumulate the content as follows: "Path=" $PATH ":/home/bin"
8. If the variable needs to be executed in another subroutine, you need to export the variable into an environment variable: "Export PATH"
9. Usually uppercase characters are system default variables, self-setting variables can use lowercase characters, easy to judge (purely according to user interests and hobbies);
10. To cancel a variable, use unset: "unset name"
For example, cancel the MyName setting: "Unset myname"
Read
To read a variable from a keyboard input
Read Atest
This is a test <== the cursor will wait for you to enter! Please enter the text on the left to see
[Email protected] ~]# echo $atest
This is a test <== you just entered
[Email protected] ~]# read-p "Please keyin your name:"-T-named
Please keyin your name:vbird Tsai <== look, there will be a hint word Fu Yi!
[Email protected] ~]# echo $named vbird Tsai
Ulimit "Restricting certain system resources for users"
Deletion substitution and substitution of variable contents
Alias Settings Alias,unalias
Data Flow re-orientation
1. Standard input (stdin): code 0, use < or <<;
2. Standard output (STDOUT): Code 1, using > or >>;
3. Standard error Output (STDERR): Code 2, using 2> or 2>>;
Save stdout not stderr to separate files.
[Email protected] ~]$ find/home-name BASHRC > List_right 2> list_error
/dev/null Trash Cans
Write Find/home-name. bashrc > List 2>&1
The basis for the judgment of the Order execution:; , &&, | |
CMD; CMD (continuous instruction release without regard to command dependencies)
CMD1 && CMD2
1. If the CMD1 is completed and executed correctly ($?=0), the CMD2 is started.
2. If CMD1 is executed and is wrong jest ($?≠0), CMD2 will not execute.
cmd1 | | Cmd2
1. If CMD1 is executed and executed correctly ($?=0), CMD2 does not execute.
2. If CMD1 is executed and is wrong jest ($?≠0), the CMD2 is started.
I don't know if/tmp/abc exists, but it's about building/tmp/abc/hehe files.
[[email protected] ~]# LS/TMP/ABC | | MKDIR/TMP/ABC && Touch/tmp/abc/hehe
Pipeline Command "| 』
Linux Learning -08-Learning Bash