What’s a Command?

OS X comes with over 1,000 commands for file manipulation, text editing, printing, mathematics, computer programming, typesetting, networking…you name it. A typical command is run in a shell by typing its program name, followed by options and arguments, like this:

wc -l myfile

The program name (wc, the “word count” program) refers to a program somewhere on your Mac that the shell will locate and run. Options, which usually begin with a dash, affect the behavior of the program. In the preceding command, the -l option tells wc to count lines and not words. The argument myfile specifies the file that wc should read and process.

Commands can have multiple options and arguments. Options may be given individually:

wc -l -w myfile           Two individual options

or combined behind a single dash:

wc -lw myfile             Same as -l -w

though some programs are quirky and ...

Get Macintosh Terminal Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.