已采纳回答 / ABrondly
当你在sh目录下时,install在当前目录不存在为真(是用elif [ ! -e "$file"] 来判断的),所以执行This is not file!当你在root目录下时,install.log存在为真(是用 elif [ -f "$file"]来判断的),所以执行This is pu tong,程序流程判断的走向,明白了么
2016-08-19
elif [ "$op" == '*' ];then
result=$(($num1*$num2))
elif [ "$op" == '/' ];then
if [ "$num2" == '0' ];then
echo 'divisor is 0!'
exit
fi
result=$(($num1/$num2))
else
echo 'please input valid operator'
exit
fi
echo "$num1 $op $num2 : $result"
result=$(($num1*$num2))
elif [ "$op" == '/' ];then
if [ "$num2" == '0' ];then
echo 'divisor is 0!'
exit
fi
result=$(($num1/$num2))
else
echo 'please input valid operator'
exit
fi
echo "$num1 $op $num2 : $result"
2016-08-08
test1=$(echo $num1 | sed 's/[0-9]//g')
test2=$(echo $num2 | sed 's/[0-9]//g')
if [ -n "$test1" -o -n "$test2" ];then
echo 'please input valid numbers'
exit
fi
if [ "$op" == '+' ];then
result=$(($num1+$num2))
elif [ "$op" == '-' ];then
result=$(($num1-$num2))
test2=$(echo $num2 | sed 's/[0-9]//g')
if [ -n "$test1" -o -n "$test2" ];then
echo 'please input valid numbers'
exit
fi
if [ "$op" == '+' ];then
result=$(($num1+$num2))
elif [ "$op" == '-' ];then
result=$(($num1-$num2))
2016-08-08
#!/bin/bash
read -t 30 -p 'please input number1:' num1
read -t 30 -p 'please input number2:' num2
read -t 30 -p 'please input operator:' op
if [ -z "$num1" -o -z "$num2" -o -z "$op" ];then
echo 'please input enough data'
exit
fi
read -t 30 -p 'please input number1:' num1
read -t 30 -p 'please input number2:' num2
read -t 30 -p 'please input operator:' op
if [ -z "$num1" -o -z "$num2" -o -z "$op" ];then
echo 'please input enough data'
exit
fi
2016-08-08
最新回答 / 给我000肉啊肉
[-e japan ]-bash: [-e: command not found如果你是这样的错误,那可能是 你没加空格 [ -e japan ] [和-e之间是有一个空格的,认真听啊,老是有强调的
2016-08-08