Library Basics

In many of the scripts in this book, you created utility functions that display error message and prompt the users for input. When two scripts needed the same function, you just copied the function from one script to the other. This method works fine when you are dealing with one or two scripts, but it breaks down with many scripts. Say you have a dozen scripts that share a function and you located a bug in that function. You can image how hard it would be to fix every one of those scripts. A repository or library of common functions would reduce the complexity of developing and maintaining these shell scripts.

What Is a Library?

Creating a library of functions is exactly like creating a shell script. The only difference between ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition 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.