3-5函数库
base.lib
add() { echo "`expr $1 + $2`" } reduce() { echo "`expr $1 - $2`" } multiple() { add() { echo "`expr $1 + $2`" } reduce() { echo "`expr $1 - $2`" } multiple() { echo "`expr $1 \* $2`" } divide() { echo "`expr $1 / $2`" } system_info() { echo "memory info" echo free -m echo echo "*************************************" echo echo "disk usage" echo df -h }
35function.sh
#!/bin.bash # . /code/lib/base.lib add 12 13 reduce 15 12 multiple 12 3 divide 12 3 system_info