Execute the specified command in place of the current shell.
Syntax exec [-cl] [-a name] [command [arguments]] Key -l Place a dash at the beginning of the zeroth arg passed to command. This is what login does. -a The shell passes name as the zeroth argument to the executed command. -c Execute Command with an empty environment.
If command is specified, it replaces the shell. No new process is created. The arguments become the arguments to command.
If command cannot be executed for some reason, a non-interactive shell exits, unless the shell option execfail is enabled, in which case it returns failure. An interactive shell returns failure if the file cannot be executed.
If command is not specified, any redirections take effect in the current shell, and the return
status is 0.
If there is a redirection error, the return status is 1.
To simply execute a shell script from the command line, just prefix the script's name with ./
./myscript
You may be tempted to fix this by adding '.' to your $PATH but this is widely considered to be a bad idea for security reasons.
A better plan is putting all shell scripts into a folder and adding that one folder to your $PATH
exec is a bash built in command.
"Power tends to corrupt, absolute power corrupts absolutely" - Lord Acton
Related:
crontab - Schedule a command to run at a later time
chroot - Run a command with a different root directory
if - Conditionally perform a command
nohup - Run a command immune to hangups
su - Run a command with substitute user and group id