exec is a functionality of an operating system that runs an executable file in the context of an already existing process, replacing the previous executable. https://en.wikipedia.org/wiki/Exec_(system_call)

exec replaces the current program in the current process, without forking a new process.

Examples to use:

exec csh

This will just replace the existing shell with csh and only need to type exit once

Within a script to startup python scripts, for example:

#!/bin/sh
ENV_FOO=$(uname -a)
exec gunicorn

In this case the exec tells sh to replace itself with gunicorn this helps to send signals directly to gunicorn

When using exec if command is not specified, any redirections take effect in the current shell:

#!/bin/sh
exec 2>&1
command

If then calling the script:

$ ./script 1> out 2> err

All the output will be combined in out