Name
exec
Synopsis
exec [command args
...] exec [-aname
] [-cl] [command args
... ]
Execute command in place of the current process (instead of creating a new process). exec is also useful for opening, closing, or copying file descriptors. The second form is for ksh93 and Bash.
Options
-
-a
Use name for the value of
argv[0]
.-
-c
Clear the environment before executing the program.
-
-l
Place a minus sign at the front of
argv[0]
, just as login(1) does. Bash only.
Examples
trap 'exec 2>&-' 0 Close standard error when shell script exits (signal 0) $exec /bin/csh
Replace shell with C shell $exec < infile
Reassign standard input to infile
Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.