Shell Functions
Any good programming language provides support for functions. A function is a bundle of statements that is executed as a group. The bundles are executed just like a “regular” command and are used to carry out often-required tasks. An advantage of a function is that it is held in the computer’s main memory, so execution is much quicker than with a script, which must be retrieved from disk. The current version of the Bourne shell supports shell functions; older versions of the Bourne shell did not. The syntax for shell functions is as follows:
name() { command-list }
This command syntax defines a function named name. The body of the function is the command-list between { and }. This list is executed whenever name is specified ...
Get Inside Solaris™ 9 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.