CHAPTER 5Accepting Command-LineOptions, Switches, andParameters

Sometimes you may want to pass optional parameters to your script, allowing its behavior to be controlled more precisely. For example, the tar archiving utility uses optional parameters. It creates archives and restores directory and file trees, but it can do so in different ways. The GNU version of tar has roughly 80 different options that can be used in various combinations to tailor the ways in which the utility performs. The major benefit of this technique is that you can write a single program and have it perform multiple tasks based on the command-line input. Additionally, you're not duplicating code by writing smaller, more specific scripts tailored to each individual task. ...

Get Expert Shell Scripting now with the O’Reilly learning platform.

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