BPARSING COMMAND-LINE OPTIONS

A typical UNIX command line has the following form:

command [ options ] arguments

An option takes the form of a hyphen (-) followed by a unique character identifying the option and a possible argument for the option. An option that takes an argument may optionally be separated from that argument by white space. Multiple options can be grouped after a single hyphen, and the last option in the group may be one that takes an argument. According to these rules, the following commands are all equivalent:

$ grep -l -i -f patterns *.c$ grep -lif patterns *.c$ grep -lifpatterns *.c

In the above commands, the –l and –i options don’t have an argument, while the –f option takes the string patterns as its argument.

Since many ...

Get The Linux Programming Interface 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.