#! /bin/bash clear function verify { if [ $1 -eq "Bob" ] && [ $2 -eq "555" ] then echo "Verified" else echo "Rejected" fi } verify Bob 555
运行时出现 (此处需要整数表达式) 错误
原因在于一个小错误:
"-eq" 对整数进行比较
"==" 对字符串进行比较,修改:
#! /bin/bash clear function verify { if [ $1 == "Bob" ] && [ $2 == "555" ] then echo "Verified" else echo "Rejected" fi } verify Bob 555
原文地址:http://blog.csdn.net/wu20093346/article/details/44945943