Shell中的函数库

函数库:

!/bin/bash

函数库的作用:在写一个大型脚本时候,

有些代码可以被多个脚本重复使用进行封装

function add {
echo "expr $1 + $2"
}
function reduce{
echo "expr $1 - $2"

}

function multiple{
echo "expr $1 \* $2"
}
function divide{
echo "expr $1 / $2"

}

脚本调用:

!/bin/bash

这个文件是一个引用文件

. base_function
add 12 23
reduce 90 30
multiple 12 12
divide 12 2

猜你喜欢

转载自www.cnblogs.com/itor/p/12164129.html