TrumanWong

exec

Call and execute the specified command

Supplementary instructions

exec command Command used to call and execute instructions. The exec command is usually used in shell script programs to call other commands. If you use a command in the current terminal, the terminal will exit immediately after the specified command is executed.

grammar

exec(options)(parameters)

Options

-c: Execute the specified command in an empty environment.

Parameters

Instruction: The instruction to be executed and the corresponding parameters.

Example

First use the echo command to output the text "Linux C++" and enter the following command:

echo Linux C++ # Output specified information

After executing the above command, the following information will be output:

Linux C++ # Output information

Then use the exec command to call the echo command to output the same information, and compare the output information. The input instructions are as follows:

exec -c echo Linux C++ # Call command

After executing the above command, the output information is as follows:

Linux C++ #Use specified instructions to output information

By comparing the execution results of the two, it can be seen that the functions implemented are the same, that is, using the exec command to call the echo command is successful.