Cover by Ron Peters

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

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. ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required