Linux Command Execution judgment basis --;, &, |
Command Execution judgment basis --;, &, |
Multiple commands are executed simultaneously during Linux O & M or during daily Linux system operations. In this case, we need to process multiple commands.
1.
Use the semicolon (;) to execute multiple commands, for example:
# Sync; shutdown-h now
2.
Determine the execution of the command, &/| example:
Cmd1 & cmd2:
If the execution of cmd1 is complete and executed correctly ($? = 0), then begin to execute cmd2
If the execution of cmd1 is complete and the execution is incorrect ($ ?! = 0), enabling cmd2 is not executed
Cmd1 | cmd2:
If cmd1 is correctly executed after execution ($? = 0), then cmd2 is not executed.
If the execution of cmd1 is complete, it is an error ($ ?! = 0), only cmd2 is executed.
Exercise the following exercise questions based on the Content learned above:
1.
Create an lshome file if the/home directory exists.
# Ll/home & touch/home/lshome
2.
Determine whether the file/tmp/abc exists. If/tmp/abc does not exist, create
# Ls-l/tmp/abc | mkdir/tmp/abc
3. Check whether the/home/Samlee directory exists. If yes, "exist" is displayed. If not, "not exist" is displayed"
# Ls-l/home/Samlee & echo "exist" | echo "not exist"
10 Linux Interview Questions and Answers in different application scenarios
10 core Linux Interview Questions and answers
10 useful Linux Command Interview Questions and answers
This article permanently updates the link address: