1. Command alias: alias lm 'ls -al | more'
Cancel command alias: unalias
2. Data flow redirection
Data stream redirection is to transfer the data originally output to the screen to a file or device.
Standard input: stdin use < or <<
Standard output: stdout use > or >>
Standard error: stderr use 2> or 2>>
Example: ls -l / > ~/rootfile save the data in the root directory to rootfile
> means to clear the original content and write again >> will continue to write under the old document
cat > catfile < somefile : Edit the content of somefile first, and then output the data to catfile
3. Judgment basis for command execution
Use if you want to execute more than one program at a time; separate
If the directory exists, create a file, if not, do not create ls /tmp && touch /tmp/jason.txt
If the file does not exist to create it use || ls /tmp || touch /tmp/jason.txt
For the variable $?, if the command execution results in no error message, $?=0 will be returned
ls /tmp/jason && echo "exist" || echo "not exist"
There are at most 3 judgment conditions, namely A&&B||C
4. Pipeline command
ls -al /etc | less The content output by the ls command can be read by less, which can flip the content forward and backward
The overall pipeline command looks like this
command1 | command2 | command3 The output of command 1 is the input of command 2, and so on