AI Learning Hub › Learn AI › Self-Paced Courses › Terminal on Mac: Reading Commands Before You Run Them › Reading a Command
Module 3 · Beginner
Reading a Command
Command, option, argument. How to read a manual page, why a filename with spaces breaks without quotes, and why man rather than --help is the way into the Mac’s built-in tools.
By the end
- Name the parts of an unfamiliar command
- Read a manual page’s SYNOPSIS line
- Handle a filename containing spaces, three different ways
- Let Tab finish a path for you
- Know why
--helpis not the answer on a Mac
An unfamiliar command looks like one undifferentiated string. It is not: it has parts, they come in a predictable order, and once you can name them you can read a command you have never seen without running it to find out what it does. That skill is what Module 9 and the capstone are built on.
The parts
Take a command you will use later in the course.
Example
grep -n "Jackson" notes/research-notes.txt
grep— the command- The program to run. Always first.
-n— an option- A setting that changes how the program behaves. Options almost always start with a dash. This one asks grep to number the lines it finds.
"Jackson"— an argument- Something for the program to work on. Here it is the text to search for.
notes/research-notes.txt— a path- Also an argument, and the one worth reading most carefully, because it decides which files are involved.
A note on vocabulary. Manual pages call these options. The heading above the list varies — man rm says “The options are as follows” and man ls says “The following options are available” — but the word is the same in both. Many people say flag instead, and AI-generated explanations use the two interchangeably. They mean the same thing; this course says option because the documentation does.
Not every program parses its line identically, and some have genuinely strange conventions. But command, then options, then arguments is the shape you can expect, and it is enough to read most of what you will meet.
The manual is on your machine
Every command in this course has a manual page, and reading one is more reliable than searching the web, where half the examples are written for Linux.
Try it
man ls
ls. Press q to leave it. macOS 26.6, October 2026. Open full-size image: the ls manual page showing its NAME, SYNOPSIS and DESCRIPTION sections (opens in a new tab)The SYNOPSIS line is the part worth learning to read, because the convention is the same everywhere. Anything in square brackets is optional. An ellipsis means you can supply more than one. So ls [options] [file ...] says: you may give options, you may give one or more files, and you may give neither.
Manual pages open in a pager, which means the text scrolls rather than filling your window. Arrow keys and the space bar move through it. q quits and returns you to the prompt.
On a Mac, --help is usually not the way in. Of the twelve macOS system utilities tested for this course, none responded to --help with a help page. Eleven rejected it as an unknown option — illegal option or unrecognized option — and grep answered with a single usage line. That convention comes from Linux, and following it on a Mac produces a confusing error rather than documentation. Use man for these built-in tools. Programs you install yourself may well support --help.
Filenames with spaces
Mac filenames contain spaces constantly, and the shell handles them in a way that surprises everyone exactly once.
The practice folder has a file called My Research File.txt. From inside the notes folder, here is what happens when you ask for it without quotes.
My, one for Research, one for File.txt. The shell split the name at every space and handed cat three separate things to open. With quotes, it is one. macOS 26.6, zsh 5.9, October 2026. Open full-size image: an unquoted filename producing three errors, then the quoted form succeeding (opens in a new tab)The error count is the evidence. cat never saw a file called My Research File.txt, because the shell had already divided the line into words before cat started. Spaces are how the shell separates one argument from the next, so a space inside a name has to be protected.
Three ways to protect it, all equivalent here:
Any of these works
cat "My Research File.txt" cat 'My Research File.txt' cat My\ Research\ File.txt
Double quotes, single quotes, or a backslash before each space. For this course they do the same job. The difference between the two kinds of quote matters only once you start using shell variables, which belongs to a later course.
Let Tab do it
There is a better answer than typing any of those, and it is the one experienced users actually reach for.
Type the first few characters of a name and press Tab. The shell finishes it for you. Type cd cas and press Tab, and it becomes cd cases/.
What makes this more than a convenience is what it does with awkward names. In the notes folder, type cat My and press Tab, and zsh completes it to:
What Tab produces
cat My\ Research\ File.txt
It inserted the backslashes itself. Tab completion is the practical answer to the problem this module has just finished explaining, and it also prevents typos in long paths, which matters more as the commands get more consequential.
When more than one name matches what you have typed, Tab shows you the possibilities instead of guessing. Type a little more and press it again.
Exercise: read before you run
Work from ~/terminal-practice.
- Open
man grep. Find the SYNOPSIS line. Which parts are in square brackets, and what does that tell you? Press q to leave. - In the same manual, find the option
-nand read what it does. - Go into
notesand read the file with spaces in its name — first by typing the quotes yourself, then again using Tab. - Without running it, name every part of this command:
ls -a notes.
Check the last one
ls is the command. -a is an option, which asks it to include names beginning with a dot. notes is an argument, and specifically a relative path — so what it points at depends on which folder you are in when you run it.
That last clause is the one worth saying out loud every time. ls -a notes run from your home folder and run from the practice folder are two different commands with the same text.