In Bash scripting, a function is defined using the ‘function’ keyword or without it. The syntax for creating a function with the ‘function’ keyword is:
function functionName() {
# code goes here
}
Without the ‘function’ keyword, the syntax becomes:
functionName() {
# code goes here
}
To call a function in a bash script, simply write the name of the function as if it were a command. For example, to call a function named ‘myFunction’, you would write:
myFunction