求救!! 关于if 语句的问题

求救!! 关于if 语句的问题

请帮我解决以下问题:

脚本:
#!/bin/bash
AA=$(wc -l AA.txt | awk '{printf("%s\n",$1)}')
BB=$(tail --lines=1 BB.txt | cut --fields=3 --delimiter=,)
echo $AA 'and' $BB
if [ $AA -eq $BB ];
then
echo 'AA.txt match BB.txt'
else
echo 'AA.txt do not match BB.txt'
fi

运行结果:
67 and 67
dd: line 5: [: too many arguments
AA.txt do not match BB.txt

这种用法是否可行,如果不行有没有其他的方法可以替代???

谢谢!!!
忘了 加“ ”
谢谢 answer!!

But I did try:

if [ "$AA" -eq "$BB" ];
if [ $AA = $BB ];
if [ $AA -eq $BB ];

Never Work.

But I did try :

if [ $AA -eq 67];
if [ 67 = $BB];

It is no problem.

Can you help agan?

Thanks a lot.
if [ "$AA" = "$BB" ]   try?
这个 用 -eq 还是 =  与 AA BB变量存储的数据类型有关吧
谢谢版主的帮助, 但是还是不行.

CODE:
#!/bin/bash
AA=$(wc -l AA.txt| awk '{printf("%s\n",$1)}')
BB=$(tail --lines=1 BB.txt | cut --fields=3 --delimiter=,)
echo '$AA = '$AA 'and $BB = '$BB

echo 'TRY $AA == $BB'
if [ $AA == $BB ];
then
echo 'AA.txt match BB.txt'
else
echo 'AA.txt do not match BB.txt'
fi

echo 'TRY $AA = $BB'
if [ $AA = $BB ];
then
echo 'AA.txt match BB.txt'
else
echo 'AA.txt do not match BB.txt'
fi

echo 'TRY "$AA" = "$BB"'
if [ "$AA" = "$BB" ];
then
echo 'AA.txt match BB.txt'
else
echo 'AA.txt do not match BB.txt'
fi

echo 'TRY "$AA" -eq "$BB"'
if [ "$AA" -eq "$BB" ];
then
echo 'AA.txt match BB.txt'
else
echo 'AA.txt do not match BB.txt'
fi

echo 'TRY $AA -eq $BB'
if [ $AA -eq $BB ];
then
echo 'AA.txt match BB.txt'
else
echo 'AA.txt do not match BB.txt'
fi

RESULT:
$AA = 67 and $BB = 67  
TRY $AA == $BB
ff: [: too many arguments
AA.txt do not match BB.txt
TRY $AA = $BB
ff: [: too many arguments
AA.txt do not match BB.txt
TRY "$AA" = "$BB"
AA.txt do not match BB.txt   :neutral:
TRY "$AA" -eq "$BB"
ff: [: integer expression expected after -eq
AA.txt do not match BB.txt
TRY $AA -eq $BB
ff: [: too many arguments
AA.txt do not match BB.txt

只有 "$AA" = "$BB" 没有错误显示, 但是结果仍然不对.

实在太痛苦了!!!
不会吧。。好像没有问题了  我试了看 没有错误 结果正确
[quote:004a68463c="zhk001"]
if [ $AA -eq $BB ];[/quote]
test命令只用单括号[]的时候,右边的表达式是不允许使用变量替换的