Options and Arguments

Options are given on the command line to change the behavior of a script or program. For example, the -a option of the ls command changes the behavior of the ls command from listing all visible files to listing all files (as explained in Chapter 3). This section shows you how to use options to change the behavior of scripts.

Often you will see or hear options called arguments. The difference between the two is subtle. A command's arguments are all of the separate strings or words that appear on the command line after the command name, whereas options are only those arguments that change the behavior of the command.

For example, in the following example:

$ ls -aF fruit

the command is ls, and its arguments are -aF and

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.