UC Carpentries Workshop Series · Fall 2026

The Unix Shell

Wednesday, September 9 · 9:00 am – 12:00 pm PT · Terminal (macOS) / Git Bash (Windows)

Software Carpentry, The Unix Shell (CC BY 4.0) · today: Episodes 1–6
instructor notes →
Before we start everyone

Open a shell

macOS — Terminal

terminal Terminal — Utilities
  • Press + Space, type terminal, hit Enter
  • Or: FinderApplicationsUtilitiesTerminal

Windows — Git Bash

git bash Git Bash — App
  • Click Start (or tap the key), type git bash, hit Enter
  • Or: right-click inside a folder → Git Bash Here
  • No Git Bash? Install it — link below

Add your OS to your Zoom name - "Sam (Mac)" / "Sam (Windows)" - so helpers know which instructions apply

Setup / install: swcarpentry.github.io/shell-novice/#setup  ·  Linux: your normal terminal, nothing to install

a shell / terminal / console / command line - all the same thing: a window where you type commands and read text back
Before we start everyone

Get to the prompt

Everyone, right now

  1. Shell open (previous slide). You'll see a $ - the prompt. Don't type it; type what comes after.
  2. Data on your Desktop? shell-lesson-data.zip from swcarpentry.github.io/shell-novice/#setup, unzipped to a shell-lesson-data folder.
  3. In your shell, type these two lines:
$ cd ~/Desktop/shell-lesson-data $ ls

You should see exercise-data/ and north-pacific-gyre/.

$ whoami you $ pwd /Users/you $ cd ~/Desktop/shell-lesson-data $ ls exercise-data/ north-pacific-gyre/

Post in chat: a green check when you see those two folders, a red x if not.

Helpers: DM the setup + data links to anyone with a red x; take them into a breakout if needed.

the shell runs a read-evaluate-print loop (REPL): you type, it reads, it runs, it prints, it waits; the $ is the prompt - "ready for input"
Why the shell

Why the command line?

  • So much runs on it - installing software, remote servers, containers, and HPC job scripts all assume shell basics
  • Your commands are the record - a pipeline you can re-run is a methods section a GUI never writes down
  • It's the glue between tools - an R script, a Python model, and someone's C binary all meet in the shell
  • AI coding agents work by typing shell commands - reviewing what an agent changed needs the same skill

Where it shows up

On an HPC cluster your job is a Bash script handed to a scheduler. Reproducibility tools - Snakemake, Nextflow, Docker, CI - are shell orchestrators. AI agents like Claude Code and Cursor run in a terminal you supervise.

On Zoom: in the chat - where have you hit a wall that a terminal would have gotten you past?

the shell is the layer HPC schedulers and AI agents both sit on top of
Concept 1 discuss

Why type when you can click?

  • A GUI is great for one file. It scales badly to hundreds.
  • A CLI lets you write instructions once and run them on 1, 100, or 10,000 files
  • The commands you type are a record - save them, re-run them, share them
  • It's the on-ramp to Python, R, Git, and working on a server

Nelle's problem

Nelle is back from a 6-month survey with 1520 sample files. Each has to go through one analysis program. By hand: open, run, save - 1520 times, ~12 hours of clicking.

Today's six episodes are the steps that let her computer do that while she writes her paper.

On Zoom: in the chat - one repetitive file task that has eaten an afternoon of your time.

Unix's design rule: small pieces, loosely joined - many tiny tools that each do one job well and combine
Navigating · Episode 2

The filesystem is a tree

/ Users/ you/ (~) Desktop/ shell-lesson-data/ exercise-data/ north-pacific-gyre/
  • You are always somewhere - pwd tells you where
  • A path is the trail of names: /Users/you/Desktop
  • / root · ~ home · . here · .. one level up
  • Absolute starts at / and means the same anywhere; relative is from where you stand
Tab completes names · recalls the last command
your home directory is where a new shell starts; cd with no argument always returns there
Navigating · recap

The shape of a command

ls -F / COMMAND OPTION ARGUMENT parts separated by spaces · option changes behaviour · argument says what to act on
  • A command may take no options and no arguments (ls), or several of each
  • Capitalisation matters: -s and -S are different options
  • Miss the space - ls-F - and the shell looks for a command called ls-F
  • Don't memorise options - look them up: man ls (q quits) or ls --help
options and arguments together are parameters; options that take no value are also called flags or switches
Pipes & filters · Episode 4

Redirect, and the pipe

wc -l *.pdb | sort -n | head -n 1 the shortest file
  • > - send output to a file instead of the screen (overwrites, no prompt)
  • >> - append to a file instead of overwriting
  • | - send output straight into the next command, no temp file
  • Build a pipeline one stage at a time; read it left to right
$ wc -l *.pdb $ wc -l *.pdb | sort -n $ wc -l *.pdb | sort -n | head -n 1
tools that read standard input and write standard output snap together - Unix calls this pipes and filters
Automation · Episodes 5–6

Loops: do it to the whole list

Three files - or three hundred. You don't type the command once per file.

for thing in list_of_things do operation_using $thing done
  • for repeats the block once per item in the list
  • each pass, the loop variable holds the current item; $thing reads its value
  • the prompt changes to > while the shell waits for done - not broken, just waiting
  • echo in front of the commands = a dry run: see what it would do before it does it
this is a for loop; a variable walking a list is the same shape in every programming language you'll meet - and a script is just these commands saved in a file, run with bash

Recap

  • pwd / ls / cd - know where you are, always
  • options begin with -; man and --help list them
  • paths: / root, . here, .. up, ~ home
  • nano, mkdir, mv, cp, rm - and rm has no undo
  • * and ? match many files; the shell expands them first
  • wc counts; sort/head/tail/cut/uniq transform
  • > writes a file, >> appends, | feeds the next command
  • for … do … done repeats a command over a list
  • echo in front of a loop = a safe dry run
  • save commands in a script; "$@" lets the caller pick the files
swcarpentry.github.io/shell-novice · Episodes 1–6 · data: shell-lesson-data (CC BY 4.0) · feedback link in the Etherpad