Linux Command Execution judgment basis --, & amp;, |

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.