October 2000
Intermediate to advanced
1152 pages
26h 41m
English
As with other programming languages, shell programs also support functions. A function is a piece of a shell program that performs a particular process that can be used more than once in the shell program. Writing a function helps you write shell programs without duplication of code.
The following is the format of a function in pdksh and bash for function definition:
func(){
Statements
}
You can call a function as follows:
func param1 param2 param3
The parameters param1, param2, and so on are optional. You can also pass the parameters as a single string--for example, $@. A function can parse the parameters as if they were positional parameters passed to a shell program.
The following example is a function that displays the name ...
Read now
Unlock full access