EN
Bash - how to use function (create / call function)
0 points
This article will show you how to use function (create / call function) in Bash.
Creating a function:
xxxxxxxxxx
1
my_function () {
2
<commands>
3
}
Another way:
xxxxxxxxxx
1
function my_function {
2
<commands>
3
}
Calling a function:
xxxxxxxxxx
1
my_function () {
2
<commands>
3
}
4
5
my_function
xxxxxxxxxx
1
2
3
my_function () {
4
echo "Hello from function"
5
}
6
7
my_function
8
my_function
Output:
xxxxxxxxxx
1
Hello from function
2
Hello from function