About this guide
A shell script is the commands you would type in a terminal, saved in a file. The syntax is a little odd and has a few traps, but the part you need for computational work is small: variables and loops, three text tools (grep, sed, awk), and the format a job scheduler expects.
If the terminal itself is new to you, start with the Linux starter pack.
This guide assumes you know commands like cd, ls and cp, and how file permissions work.
Chapters
Conventions
In code boxes, a line starting with $ is a command typed at the terminal, and the rest is output.
Boxes without $ show the contents of a script file.
Other shells exist, such as zsh (the macOS default) and fish, but cluster login shells and job scripts are almost always bash.
With #!/bin/bash as the first line, a script runs under bash whatever your interactive shell is.