1
2
3
4
5
[ function ] funname [()]
{
    action;
    [return int;]
}
1
2
3
4
5
6
7
# 定义函数 fun0
fun0(){
    echo "run fun0 "
}
# 调用函数 fun0
fun0

1
2
3
4
5
6
7
# 定义带参数的函数 fun0
fun0(){
    echo "run fun0 $1 "
}
# 调用带参数的函数 fun0
fun0 foo

https://www.runoob.com/linux/linux-shell-func.html

https://wiki.jikexueyuan.com/project/shell-tutorial/shell-function-parameter.html