The set command

Set or unset values of shell options and positional parameters. 4 examples from the lessons of the IVski Linux Playground — try them in the terminal next to them.

Options in the examples

-e
Exit immediately if a command exits with a non-zero status.
-u
Treat unset variables as an error when substituting.

Examples

set

All shell variables (more than env)

set -e

Exit on error

set -u

Error on undefined variables

set -o pipefail

Catch pipe errors

Lessons that use set