函数定义、调用
bash
$ cat te.sh #!/bin/bash # define a function test() { echo "This is a function." } # test function call test $ sh te.sh
函数库文件app
编写函数库文件ide
#!/bin/bash # define func hello() { echo -n "hello $1. " credit } credit() { echo "Do you need to apply for a credit card ?" }
载入函数库文件函数
#!/bin/bash # call in . ./lib.sh hello $1
* 引用函数时不当心带上括号,会报错。
spa