语法一:
函数名(){
代码块
return N
}
语法二:
function 函数名{
代码块
return N
}
实战
#!/bin/bash
#定义函数
start(){
echo "Apache start ... [OK]"
}
stop(){
echo "Apache stop ... [FAIL]"
}
#调用函数
stop
start
start
#输出
Apache stop ... [FAIL]
Apache start ... [OK]
Apache start ... [OK]