Skip to Main Content
UNIX® Shells by Example, Third Edition
book

UNIX® Shells by Example, Third Edition

by Ellie Quigley
October 2001
Intermediate to advanced content levelIntermediate to advanced
1040 pages
22h 50m
English
Pearson
Content preview from UNIX® Shells by Example, Third Edition

12.10. Processing Command Line Options with getopts

If you are writing scripts that require a number of command line options, positional parameters are not always the most efficient. For example, the UNIX ls command takes a number of command line options and arguments. (An option requires a leading dash; an argument does not.) Options can be passed to the program in several ways: ls –laFi, ls –i –a –l –F, ls –ia –F, and so forth. If you have a script that requires arguments, positional parameters might be used to process the arguments individually, such as ls –l –i –F . Each dash option would be stored in $1, $2, and $3, respectively. But, what if the user listed all of the options as one dash option, as in ls –liF? Now the –liF would all be ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

UNIX® Shells by Example Fourth Edition

UNIX® Shells by Example Fourth Edition

Ellie Quigley
Storage Area Networks For Dummies®

Storage Area Networks For Dummies®

Christopher Poelker, Alex Nikitin

Publisher Resources

ISBN: 013066538XPurchase book