exec
Quick Reference
Command Name:
exec
Category:
shell builtin
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
- 1
Process replacement
Replace the current shell with another program without creating a new process
- 2
Resource conservation
Avoid creating nested processes in scripts
- 3
File descriptor manipulation
Permanently redirect I/O for the remainder of a script
- 4
Shell script chaining
Transfer control from one script to another without returning
Syntax
exec [-cl] [-a name] [command [arguments...]]
Options
Option | Description |
---|---|
-a name |
Pass name as the zeroth argument to command |
-c |
Execute command with an empty environment |
-l |
Place a dash in the zeroth argument to command (for login shells) |
Examples
How to Use These Examples
The examples below show common ways to use the exec
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.