Functions
Defining functions
function_name () {
commands
}
or
function function_name {
commands
}
Function return value
#!/bin/bash
my_function () {
echo "some result"
return 55
}
my_function
echo $?
Output:
some result
55
Function parameter
#!/bin/bash
greeting () {
echo "Hello $1"
}
greeting "Joe"
Output:
Hello Joe