Unix Shell Script Creating Functions
June 15, 2007 by Mark Marucot
Functions are named code blocks that can be referenced and executed as a unit. Functions have an option to take variable number of arguments and may return a value. If function returns a value, calling the function is usually part of an expression.
Syntax
CODE:
-
name() {
-
statements
-
}
Example
CODE:
-
#!/bin/sh
-
sum() (
-
echo $(($A + $B))
-
)
-
A=2
-
B=5
-
sum $A $B




Comments
Feel free to leave a comment...
and oh, if you want a pic to show with your comment, go get a gravatar!