MenuMenuCoursesTutorialsGlossaryCommandsLinux BasicsBash ScriptingUbuntuNetworkingBash ProgrammingLinux ApplicationsMiscellaneousCheat SheetsForumAbout HomeHomeHome > > Bash Scripting TutorialBash Scripting TutorialBash Scripting Tutorial > > Bash FunctionsBash FunctionsBash Functions > > How to Call a Function in Bash [7 Cases]How to Call a Function in Bash [7 Cases]How to Call a Fu..." /> MenuMenuCoursesTutorialsGlossaryCommandsLinux BasicsBash ScriptingUbuntuNetworkingBash ProgrammingLinux ApplicationsMiscellaneousCheat SheetsForumAbout HomeHomeHome > > Bash Scripting TutorialBash Scripting TutorialBash Scripting Tutorial > > Bash FunctionsBash FunctionsBash Functions > > How to Call a Function in Bash [7 Cases]How to Call a Function in Bash [7 Cases]How to Call a Fu..." /> How to Call a Function in Bash [7 Cases] - LinuxSimply

How to Call a Function in Bash [7 Cases]

Calling Bash functions is as simple as invoking a Bash command. To call an already-declared Bash function, use the function name as if it were a Bash command. For instance, to invoke a function declared as fname() { command; }, type fname in the terminal or within the script where the function is defined. This article talks about 7 different cases of calling functions in the Bash shell.

1. Calling a Function Defined in the Terminal

Think about a function defined in the terminal as follows:

func1 () {
echo "Hello from a Bash function"
}