20.3. Conclusion

Being able to correctly handle command line options makes your scripts look professional; to the user they appear just like any other system command. This chapter has shown two methods of handling command line options, using shift and using getopts. The amount of checking code required in using getopts is far less than if you were to use the shift method.

Shift also overcomes the limitation of the $1..$9 parameters you can pass to your scripts. Using shift your script can simply shift its way up through all the arguments called, so the script can then get on with some processing.

Get Linux and Unix Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.