Bash knowledge points

Source: Internet
Author: User
Tags builtin
1. Differences between builtin command, external command, and bash script. Use builtin command (hash, type, command) instead of the which command (external command) to check whether a command is installed (related to the PATH variable ): hash Foo>/dev/null 2> & 1 | echo "I need the command but it not exist" or command-V Foo>/dev/null 2> & 1 | echo "I need the command but it not exist" or type Foo>/dev/null 2> & 1 | echo "I need the command but it not exist" 2. command Execution Process 2.1 builtin command will be executed inside bash, without the Fork sub-process 2.2 External command is a common binary file, Fork sub- Shared environment variables of the parent process. 2.3 bash Script: starts a sub-process (exec/bin/bash) to explain the script content, recursively execute internal external command and bash script. PS xjf can be used for viewing. The HELP command can be used to view all builtin command 3. A | B processes, and the parent and child processes communicate through the anonymous pipeline. 4. commands in sub-shell () are executed in a sub-shell, and the command execution result does not affect the current shell. A = Hello; echo $ A | read var; echo $ var VSA = Hello; echo $ A | (read var; echo $ var) 5. optimizing bash performance: 5.1) Use less pipelines and use more files as command parameters. Generally, standard input and standard output are accepted, and files are introduced as parameters. 5.2) Use less pipelines and use more here documents. Read var <$ (echo "hi"); echo $ var 5.3) Use less external commands and builtin Command 6 more. obfuscated points 6.1) test [] [[] () have the same efficiency and are all builtin commands. You can use the help command to view details.

Bash knowledge points

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.