shell 命令



函数

函数定义方法

1
2
3
4
5
6
7
function function_name {
    ...
}

function_name () {
    ...
}

函数传参

1
2
3
4
5
6
# test.sh
test () {
    echo "function name:$0 Parameter #1 is $1"
}

test 20

执行结果

1
2
$ ./test.sh
function name:test Parameter #1 is 20

words64
tagsshell bash linux
lastmod2023-07-09
footer test line hide