작성
·
402
0
==========================실행시 에러 로그=================================
[root@c function]# ./use_cal.sh
/s/lang/function/cal: line 3: syntax error near unexpected token `echo'
/s/lang/function/cal: line 3: ` echo " $1 + $2 = " '
./use_cal.sh: line 5: plus: command not found
./use_cal.sh: line 6: minus: command not found
./use_cal.sh: line 7: multi: command not found
./use_cal.sh: line 8: div: command not found
./use_cal.sh: line 9: div: command not found
=================================================================
vi cal
function plus{
echo " $1 + $2 = "
echo $[ $1 + $2 ]
echo
}
function minus{
echo " $1 - $2 = "
echo $[ $1 - $2 ]
echo
}
function multi{
echo " $1 * $2 = "
echo $[ $1 * $2 ]
echo
}
function div{
echo " $1 / $2 = "
if [ $2 -eq 0]
then
echo " 0 으로 나눌수 없음"
else
echo $[ $1 / $2 ]
fi
echo
}
====================================================
vi use_cal.sh ---> chmod 700
#!/bin/bash
source ./cal
plus 30 40
minus 10 3
multi 11 7
div 2 0
div 14 2
============================================================
아갑사합니다!