Functions

Functions are predefined groups of statements that can be called with a single command. They can almost be thought of as mini-programs inside other programs. Using functions in your shell programs can make your life a lot easier for two reasons. First, if you need to perform a complex operation in multiple places in your program, you can simply type the name of the function rather than having to retype all the code each time you need to perform the operation. Secondly, if you later decide you need to make the operation work differently, you only have to change the function rather than go through the code and change it every place it is used. The example in Listing 10.20 demonstrates how a function is created; it shows a simple function ...

Get FreeBSD6 Unleashed 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.