linux-tutorial/codes/shell/脚本函数/lib.sh

22 lines
216 B
Bash
Raw Normal View History

2020-01-03 22:41:37 +08:00
#!/usr/bin/env bash
add() {
echo $[ $1 + $2 ]
}
sub() {
echo $[ $1 - $2 ]
}
mul() {
echo $[ $1 * $2 ]
}
div() {
if [[ $2 -ne 0 ]]; then
echo $[ $1 / $2 ]
else
echo -1
fi
}