Sams Teach Yourself Shell Programming in 24 Hours
(Publisher: Macmillan Computer Publishing)
Author(s): Sriranga Veeraraghavan
ISBN: 0672314819
Publication Date: 01/01/99

Previous Table of Contents Next


Conclusion

In this chapter you examined how to deal with arguments and options in shell script. Specifically you looked at the following methods:

  Manually handling arguments and options using a case statement
  Handling options using getopts

You worked through two examples that illustrate the implementation and rationale behind each method. In addition, you saw several special variables that pertain to arguments and command execution.

As you will see in later chapters, using options greatly increases the flexibility and the reusability of your shell scripts.

Questions

1.  Add tar file extraction to the mytar script.
Assume that the –x option indicates that the user wants to extract tar files and that the correct value of TARGS for extracting tar files is -xvf.
2.  Add the extract option to the uu script. Assume that the –x option indicates that the file should be extracted, and that the command
uudecode $INFILE

is used to extract a uuencoded file.


Previous Table of Contents Next