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