O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required