增加可读性
函数
#!/bin/bash# funcfunction apache_install() { echo -e "\033[32mThe apache server wait install...\033[0m"}apache_install
效果
# /bin/bash func.sh The apache server wait install...
加参数
#!/bin/bash# funcfunction apache_install() { echo -e "\033[32mThe apache server wait install...\033[0m" echo $1}apache_install '我是参数1'
执行效果
# /bin/bash func.sh The apache server wait install...我是参数1
全局变量
#!/bin/bash# funcGLOBAL_VAR='我是全局变量'function apache_install() { echo -e "\033[32mThe apache server wait install...\033[0m" echo $1 echo $GLOBAL_VAR}apache_install '我是参数1'
执行效果
# /bin/bash func.sh The apache server wait install...我是参数1我是全局变量