O'Reilly logo

Linux in a Nutshell, 6th Edition by Robert Love, Stephen Figgins, Ellen Siever, Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

exec

Synopsis

exec [-a name] [-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.

Options

-a name

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.

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required