Linux Bash shell provides the exec command in order to create a new process for the provided command and replace it with the current bash shell process. The exec command derived from the bash low-level exec() method. The exec command executes provided command with the provided arguments.
exec Command Syntax
The bash exec command has the following syntax.
exec OPTION COMMAND PARAMETER
- OPTION is related with the exec command to provide different options. This is optional.
- COMMAND is the command or script which run as a new process. This is required.
- PARAMETER is the COMMAND parameter and not related with the exec. This is optional.
Execute New Command
By default the provided command or script is executed under the parent process as a child process.
Redirect Current Bash Output Into A File
By default the bash shell display output in the current shell. But the exec command can be used to redirect all outputs into a file. After the redirection set, all output is redirected into the specified file and no content output displayed on the current shell.
exec > output.txt