Linux Shell programming bash internal commands

Source: Internet
Author: User
Bash commands explain that a package contains some internal commands that are invisible to the directory list. they are provided by the Shell itself. common internal commands include echo, eval, exec, e.

Bash commands explain that a package contains some internal commands that are invisible to the directory list. they are provided by the Shell itself. common internal commands include echo, eval, exec, export, readonly, read, shift, wait, and point (.), the following describes the command format and functions.

1. echo

Command format: echo arg

Function: displays the string specified by arg on the screen.

2. eval

Command format: eval args

Function: when the Shell program runs the eval statement, the Shell reads the args parameter and combines them into a new command and then runs it.

3. exec

Command format: exec command parameters

Function: when the Shell executes the exec statement, it does not create a new sub-process, but instead executes the Specified Command. when the specified command is executed, the process (that is, the initial Shell) is terminated, so the statements after exec in the Shell program will not be executed.

4. export

Command format: export variable name or: export variable name = variable value

Function: Shell can use export to bring its variables down to the sub-Shell, so that the sub-process inherits the environment variables in the parent process. However, the sub-Shell cannot use export to bring its variables up to the parent Shell.

Note: the export statement without any variable name will display all the current export variables.

5. readonly

Command format: readonly variable name

Function: identifies a user-defined Shell variable as unchangeable. The readonly command without any parameters will display all read-only Shell variables.

6. read

Command format: read variable table

Function: Read a row from a standard input device, break it into several words, and assign values to variables defined in the Shell program.

7. shift statement

Function: the shift statement renames all location parameter variables as follows, that is, $2 becomes $1, $3 becomes $2... Every shift statement used in the program makes all the location parameters move one position to the left in sequence, and the location parameter $ # minus 1 until it is reduced to 0.

8. wait

Function: enables Shell to wait for all sub-processes started in the background to end. The return value of wait is always true.

9. exit

Function: exit the Shell program. After exit, you can selectively specify a digit as the return status.

10. "." (point)

Command format:. Shell program file name

Function: enables Shell to read the specified Shell program file and execute all statements in the file in sequence.

Related Article

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.