User-Defined Functions

You can write your own functions in the Bourne and Korn shells and use them as part of other scripts.

NOTE

Not all Bourne shells support functions. However, the Solaris Bourne shell does support functions.

User-defined functions are useful if you have a series of commands that you want to use repeatedly. The functions written for an application server are an example of user-defined functions. Some examples of functions are provided in “Example Scripts”. When you define a function, you use the name of the function at the place where you want to execute the series of commands contained in the function.

Typically, you define functions at the beginning of a script, but you can define them in separate files and share them between ...

Get Solaris™ 8 Advanced System Administrator's Guide, Third 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.