函數定義、調用
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