Command line

Anatomy of the command line

This example shows a complex command on the command line. Notice how the parts are separated by spaces.

This is the anatomy of the command line:

part what it does
prompt The prompt indicates that the computer is ready for your command. Usually the word is the name of the current directory. The $ indicates you can type here ($ is common, but some systems use a different symbol).
command The name of the command or program you want to execute.
options Options are prefixed with hyphens (-) and change the way the command behaves. Often a command has no options.
arguments The arguments tell the command what things you want it to operate on. Some commands don’t have arguments.

About this command

The example in the diagram shows the enter key being tapped twice (which issues no command — it’s like a tennis player bouncing the ball a couple of times before serving), and then issuing a grep command.

The grep command1 searches files for patterns. This example will print out all the lines in any text files (*.txt) in the current directory (notes) that contain the word needle. The search will be case-insentive (-i) and only full word matches are considered (-w) (so “needles” or “needless” won’t match, but “needle” will).

You won’t remember all the options of all the commands you need (although you will learn the ones you use the most). On Unix systems, you can look them up using the man (manual) command.

1 “grep” = globally search for a regular expression and print matching lines.