function 其實很簡單,可是有時候卻能節省不少時間和代碼 bash
基本寫法: code
#!/bin/bash function A(){ …… } function B(){ …… } #調用 A B
實例 three
#!/bin/bash function printInfo() { echo "Your choice is $1" } case $1 in "one") printInfo 1 ;; "two") printInfo 2 ;; "three") printInfo 3 ;; "four") printInfo 4 ;; esac exit 0
調用方法時加一個參數便可 it
A.sh one io