March 2002
Beginner
504 pages
10h 47m
English
Functions are defined as follows:
name () { list ; }
Here, name is the name of the function and list is a list of commands. The list of commands, list, is referred to as the body of the function. The parentheses, ( and ), that follow name are required.
The job of a function is to bind name to list, so that whenever name is specified list is executed. When a function is defined, list is not executed; the shell parses list to ensure that there are no syntax errors and stores name in its list of commands. The following example illustrates a basic function definition:
lsl() { ls –l ; }
Here you define the function lsl and specify list as ls –l.
An alternative form of function definition is available in ksh, bash, and zsh:
function ...
Read now
Unlock full access