The syntax for creating a bash function is very easy. They can be declared in two different formats:
~/.bashrc
...
function_name () {
[commands]
}
...
or
~/.bashrc
...
function function_name {
[commands]
}
...
To pass any number of arguments to the bash function simply, put them right after the function’s name, separated by a space. The passed parameters are $1, $2, $3, etc., corresponding to the position of the parameter after the function’s name. The $0 variable is reserved for the function name.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.