Shell basics-execution of bash Programming

Source: Internet
Author: User

ShellIntroductionBashProgramming execution

There are five methods to execute a command in the Bourne Shell, and the results of these five methods are different:
: Run the following command directly: This method is the same as using the command in the command line.
: Use the sh command: the file must be a Bourne Shell script, but this file does not have to be set
Executable. In addition, it is the same as using commands directly.
: Use the "." command: It is similar to the sh command, but it does not generate a new process like sh.
In the original process.
: Execute command exec command: the script will be replaced by the executed command. After the command is executed
And the script ends.
: Replace with a command: This is a very useful method. If you want to make the output of a command a parameter of another command
This method must be used. We place the command line in two "'" symbols.
For example:
Str = 'current directory is ''pwd'
Echo $ str
The result is as follows:
Current directory is/home/dfbb
This means that the command pwd outputs "/users/cc/mgtsai", and then the entire string replaces the original pwd to set the str variable,
Therefore, the str variable contains the output of the pwd command.

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.