#!/bin/bash
function1() {
do whatever ...
}
function2() {
do whatever ...
}
case "$1" in
function1) # this is the name of the argument triggering the function - could be different, for instance f1
function1 # this is the name of the function to run
;;
function2) # this is the name of the argument triggering the function - could be different, for instance f2
function2 # this is the name of the function to run
;;
*)
echo "Usage: $0 {function1|function2}"
;;
esac
您可以制作脚本文件,以便它定义一些函数,并运行作为第一个参数给出的函数
$1
。像这样: