各位高手看过来

sh/bash/dash/ksh/zsh等Shell脚本
回复
yjgyjg1997
帖子: 10
注册时间: 2006-10-25 20:42

各位高手看过来

#1

帖子 yjgyjg1997 » 2006-11-18 12:02

#!/bin/bash
clear
function verify
{
if [ $1 -eq "Bob" ] && [ $2 -eq "555" ] ; then
echo "Verified"
else
echo "Rejected"
fi
}
verify Bob 555

结果: line 5: [: Bob: integer expression expected
这是为甚模呀?多谢指点 :idea: :idea:
aBiNg
帖子: 1331
注册时间: 2006-07-09 12:22
来自: 南京

Re: 各位高手看过来

#2

帖子 aBiNg » 2006-11-18 13:06

结果: line 5: [: Bob: integer expression expected
"-eq"只能用于整型数据比较,而"Bob"属string,必须要用"="操作符比较.
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

#3

帖子 bones7456 » 2006-11-19 16:51

学习了,呵呵!
回复