LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 764|回复: 3

请问这段shell什么地方不对

[复制链接]
发表于 2005-9-27 15:24:18 | 显示全部楼层 |阅读模式
#!/bin/bash
echo Please, enter your firstname and lastname
read FN LN
echo $FN
echo $LN

if [  "$FN"="$LN" ];
then
  echo First is same to Last!
else
  echo different!
fi


为什么我输入
aaa bbb 回车

答案是  First is same to Last!

什么地方不对啊
发表于 2005-9-27 15:46:51 | 显示全部楼层
我想只要把if[“$FN"="$LN"]后面的那个引号去掉就可以了
回复 支持 反对

使用道具 举报

发表于 2005-9-27 22:41:30 | 显示全部楼层
Hi, 1 && 2
1. Remove the semicolon at the end of "if" line or move the "then" after it
2. Put spaces around all your operators. I've highlighted the mandatory spaces with the word 'SPACE' - replace 'SPACE' with an actual space; otherwise, it won't work:
if SPACE [ SPACE "$1" SPACE = SPACE "$2" SPACE ]
回复 支持 反对

使用道具 举报

发表于 2005-9-27 23:10:56 | 显示全部楼层
if [ "$FN" = "$LN" ]
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表