builtin
Bash exec
With no command operand, applies redirections to the current shell; with a command, successful exec replaces the shell process. This example tests redirection only.
Formal Syntax & Structure
bash syntaxbash
exec [options] [command [arguments]] [redirections]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| command | command | Optional replacement program. |
Return Value
exit status
With no command operand, applies redirections to the current shell; with a command, successful exec replaces the shell process. This example tests redirection only.
Working Example
Example Snippetbash
( exec 3>&1 exec > trace.log printf 'inside\n' exec 1>&3 exec 3>&- printf 'restored\n')cat trace.log