Shell function provides a way of mapping a name to a list of commands. Shell function can be compared with subroutines or procedures or functions of programming languages.
The main difference is that a new instance of the shell begins in order to run a shell script, whereas functions run in the current shell.
The following examples illustrate valid and invalid function definitions:
Invoking a Function
To invoke a function, only its name is required, thus typing
on the command line executes the lsl() function, but typing
does not work because sh interprets this as a redefinition of the function by the name lsl.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.