Glossary termProgramming practice

Shell Scripting

Also known as: Shell script, Bash scripting

Writing programs for a command-line shell, such as Bash, that automate sequences of commands, file operations and system administration tasks.

Shell scripting is the practice of writing programs, called shell scripts, that are executed by a command-line shell. A script is a text file containing the same commands a person could type at the command line, along with variables, conditionals, loops and functions that let it make decisions and repeat work. A short script might back up a folder, rename hundreds of files, check whether a website is responding or set up a development environment. On Unix-like systems, a first line beginning with the characters #! names the interpreter that should run the file.

The Bourne shell, written by Stephen Bourne at Bell Labs and distributed with Version 7 Unix in 1979, established the scripting language that most Unix shells still follow, and the POSIX standard later codified a common core. Bash, written by Brian Fox for the GNU project and released in 1989, became the default shell on most Linux distributions. Other shells include zsh, the default on macOS since 2019, and fish, while Windows has PowerShell, which passes structured objects between commands rather than plain text.

Shell scripts are the glue of system administration and DevOps work, appearing in build processes, deployment steps, cron jobs and container setup files. Their strength is direct access to every command-line tool on a system. Their weaknesses are well known: unquoted variables, word splitting and silently ignored failures cause subtle bugs, and passing untrusted input into commands can create command injection vulnerabilities. Common safeguards include quoting variables, enabling stricter error handling and checking scripts with linters such as ShellCheck. Larger or more complex tasks are often better written in a general-purpose language such as Python.

Key points

  • A shell script is a text file of shell commands plus control structures, run by a shell such as Bash.
  • The Bourne shell of 1979 set the scripting conventions that most Unix shells still follow.
  • Scripts automate builds, deployments, backups and scheduled jobs across Unix-like systems.
  • Quoting variables, strict error handling and linting with tools such as ShellCheck prevent common shell bugs.

Related entries

Technology

Bash

ProgrammingDevOpsFOSS

Unix shell and command language written for the GNU Project, long the default interactive shell and scripting language on Linux systems.

Glossary term

Command-Line Interface

ProgrammingFOSS

Text-based interface in which users interact with a computer by typing commands and reading text output rather than using graphical menus.

Glossary term

Cron

DevOps

Time-based job scheduler in Unix-like operating systems that runs commands or scripts automatically at specified times, dates or intervals.

Glossary term

Linting

Programming

Automated checking of source code for likely errors, suspicious constructs and style violations using a tool called a linter.

Glossary term

DevOps

DevOpsIdeas and Culture

Set of cultural practices and tools that unites software development and IT operations to deliver changes faster and more reliably.

Technology

Python

Programming

High-level, general-purpose programming language created by Guido van Rossum, known for readable syntax and widely used in data science and AI.

Glossary term

Compact pattern language for describing sets of strings, used to search, match, validate and transform text in programs and command-line tools.

Glossary term

Use of software to carry out sequences of tasks automatically, triggered by events or schedules, with little or no manual intervention.

Referenced by

Other entries that discuss or point to Shell Scripting.