IT lexicon › Programming › Shell script

Shell script

Programming På svenska → Updated: 2026-07-29

A program written in the shell's own language. The glue of Unix: run commands, connect them with pipes, check exit codes. The first line names the interpreter — #!/bin/bash.

The strength is that the whole system is already your library; ten lines can do what takes a hundred in a real programming language. The weakness is that the language is full of traps: unquoted variables split on whitespace, misspelled names silently expand to nothing, and a pipeline returns only the last command's status. Which is why experienced scripts open with set -euo pipefail and quote everything. shellcheck catches most of what still slips through. Write in POSIX sh if the script must be portable, in Bash if you need arrays and [[ ]]. The old rule of thumb holds: once a script passes a couple of hundred lines or needs real data structures, switch to Python.

← Back to the lexicon