Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 13: Handling User Input > Working with Options

Working with Options

If you've been following along in the book, you've seen several bash commands that provide both parameters and options. Options are single letters preceded by a dash that alter the behavior of a command. This section shows three different methods for working with options in your shell scripts.

Finding Your Options

On the surface, there's nothing all that special about command line options. They appear on the command line immediately after the script name, just the same as command line parameters. In fact, if you want, you can process command line options the same way that you process command line parameters.

Processing Simple Options

In the test13 script earlier, you saw how to use the shift command to work your way down the command line parameters provided with the script program. You can use this same technique to process command line options.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial