O'Reilly logo

Expert Shell Scripting by Ron Peters

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

CHAPTER 2Standard Function Library

After writing many scripts, I realized there were several functions and routines I was using repeatedly. Sometimes I would write the code for these duplicated functions again, and other times I would copy and paste the code from an earlier script. But the best coding practice is to keep a file around that contains all of your already tested and working functions. This creates a scriptwriter's toolbox, or, in programming speak, a library. With a library in place, many of the tools you need often are close at hand and you don't have to code the functions anew each time you need them. This chapter shows you how to set up a standard function library and how to utilize the library in your scripts.

The Library File ...

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