Hour 13. Parameters

As you saw in previous chapters, the general format for the invocation of programs in UNIX is

						cmd
						opts
						files
					

Here cmd is the command name, opts is any option that you need to specify, and files is an optional list of files on which the command should operate. Consider the following example:

$ ls -l *.doc

Here ls is the command, -l is the only option, and *.doc is the list of files for ls to operate on.

Because most UNIX users are familiar with this interface, it is best to use this format in shell scripts. This means that scripts that can have options must be able to read and interpret them correctly.

This chapter examines the following topics related to the handling of options passed to a shell script:

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition 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.