What are functions?
-Functions are used to perform a repetitive task to reduce repetition within a shell script.
-Functions can be considered to be mini shell scripts that run within a shell script (think nesting).
-Arguments can be used in functions since they are essentially shell scripts themselves.
Example of a function:
#function.
see()
#Instructions to be performed when function is called.
echo "Here are users on $HOST"
echo
who -T | grep "+"
}
#calling the function in your script.
see
#end of example
-To run this function just type/call "see" anywhere in the script after your actual function and it will run.
No comments:
Post a Comment