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.