exec

Official Description

If an argument is given, the command specified by the argument is executed in place of this shell without creating a new process.

Syntax

exec [argument ...]

Options

-c clears variables before execution.

-a assigns a different name to the command being run.

Oddities

Options -a and -c are available in ksh93 and beyond.

If no arguments are given, the effect of this command is to modify file descriptors through redirection.

File descriptors > 2 opened with exec are closed when the shell exits.

Example

 $ ksh # Create new ksh $ $ print $$ # Display pid 4088 $ $ exec csh # Use exec to run a different shell % %echo $$ # Note pid is the same 4088 % %ksh # Run a different shell without using exec $ $ print $$ # Note different ...

Get Korn Shell Programming by Example 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.