shell script
A text file of shell commands that runs them in order, top to bottom, as if you had typed them one by one.
In more detail
Scripts are quick to write, but they describe steps rather than a result, so running one twice performs every step twice. It must be executable, or be passed to a shell such as bash, to run.
Examples
bash setup.shRunning setup.sh twice appended the same configuration line twice, which a playbook describing the line as present does not do.bash tests/run.sh.git/hooks/commit-msg is a short shell script Git runs before recording a commit.Related terms
- shell — The program that reads the commands you type, runs them and shows the results; sh and bash are common ones.
- shebang — The first line of a script, starting with #!, that names the program the operating system should use to run it.
- idempotency — The property of an operation that gives the same result whether you run it once or many times, because a repeat run finds nothing left to do.
- playbook — A YAML file containing one or more plays, which together describe the state Ansible should bring a set of hosts to.
- execute permission — The permission that lets a file be run as a program, or lets you enter a directory.
- source builtin — The builtin that runs a file's commands in the current shell instead of in a new one; the POSIX spelling is a single dot.
- Bash — The GNU shell: a program that reads commands, typed or from a script, and runs them.
- set -e — The shell option that makes a script exit as soon as a command fails, instead of carrying on.
- run step — A workflow step whose run key holds shell commands for the runner to execute.
- Git hook — A script Git runs automatically at a point in its workflow, such as pre-commit, which can stop the commit by exiting non-zero.
- exit code — A number a process returns when it finishes: 0 means success, anything else means something went wrong.
Taught in
- What Configuration Management Is — Ansible Configuration Management at Scale
- Dynamic Inventory — Ansible Configuration Management at Scale
- What A Shell Is, And What Bash Is — Bash Scripting & Command Line Automation
- Which Shell Am I In, And Getting Bash Five — Bash Scripting & Command Line Automation
- Shebangs, Permissions And Three Ways To Run — Bash Scripting & Command Line Automation
- Exit Codes, And What Success Means — Bash Scripting & Command Line Automation
- Conditionals: test, Brackets, Double Brackets, case — Bash Scripting & Command Line Automation
- Loops: for, while, until, break, continue — Bash Scripting & Command Line Automation
- Arguments: Dollar One, Dollar At, shift — Bash Scripting & Command Line Automation
- ShellCheck — Bash Scripting & Command Line Automation
- Style That Prevents Bugs — Bash Scripting & Command Line Automation
- POSIX sh Versus Bash — Bash Scripting & Command Line Automation
- Archives, Transfers And The Network — Bash Scripting & Command Line Automation
- Scheduling, Monitoring And A Script That Reports — Bash Scripting & Command Line Automation
- What Is a Pipeline? — Continuous Integration & Continuous Delivery Pipelines
- Triggers and the Event Model — Continuous Integration & Continuous Delivery Pipelines
- Passing Data Between Jobs: Artifacts — Continuous Integration & Continuous Delivery Pipelines
- Sync Waves and Dependency Management — Continuous Integration & Continuous Delivery Pipelines
- Conventional Commits — Advanced Git Internals & Distributed Workflows
- Exam Strategy: The First Fifteen Minutes And ansible-doc — RHCE in Ansible (EX294): Automate Red Hat Systems
- ansible-navigator: The Settings File The Exam Reads — RHCE in Ansible (EX294): Automate Red Hat Systems
- Ansible Vault: Secrets Encrypted, Runs Without A Prompt — RHCE in Ansible (EX294): Automate Red Hat Systems
- Mock Exam, Part 2: Real Machines And The Patterns That Fail — RHCE in Ansible (EX294): Automate Red Hat Systems