Sean's Personal Code Samples And References

Execute a command

      exec [-cl] [-a name] [command [arguments]]

      -l   Place a dash at the beginning of the zeroth arg passed to command.
           (This is what the login program does.)

      -c   Causes command to be executed with an empty environment.

      -a   The shell passes name as the zeroth argument to command.
If command is supplied, it replaces the shell without creating a new process. If no command is specified, redirections may be used to affect the current shell environment. 

If there are no redirection errors, the return status is zero; otherwise the return status is non-zero.

exec is a bash built in command.

To run an executable file or a shell script from the command line it is often not necessary to use exec at all, just prefix the filename with ./ 
bash will only search the path not the current working directory for the file.

To execute a program/script in the current working directory use:


You may be tempted to 'fix' this by adding '.' to $PATH but this is widely considered to be a bad idea for security reasons.

Sean Marcellus
There are 10 kinds of people e in this world, those who understand binary and those who don’t.