The exec command is used to replace the current shell; in other words a subshell is not started. When using this command all existing environments are cleared to start afresh. The general format is:
where command is generally a script.
The best description I can think of in explaining exec is to think of it as trampling over your current shell.
When the script has finished the session can be terminated. One of the many uses of exec is to run added security scripts, usually put at the end of the user’s .profile file. If the user inputs an invalid response, the shell is closed and they are back at the login prompt. Exec is also popular when opening files with file descriptors.
Be aware when using exec with file descriptors ...