分页: 1 / 1

[问题]新手提问简单的问题

发表于 : 2007-02-01 16:59
kaixinlaohe
#!/bin/bash
strvar="hello"
#定义一个字符串变量
if [${strvar} = "he"] 是否与he相等
then
echo correct
else
echo wrong
fi

运行的时候出现了这个错误是怎么回事啊?
[he: command not found

发表于 : 2007-02-01 23:18
firefish
bash的相等好像不是这样比较的吧,自己搜搜看,这好像连C语言里面都不是这么比较 的

Re: [问题]新手提问简单的问题

发表于 : 2007-02-01 23:51
5451vs5451
kaixinlaohe 写了:#!/bin/bash
strvar="hello"
#定义一个字符串变量
if [${strvar} = "he"] 是否与he相等
then
echo correct
else
echo wrong
fi

运行的时候出现了这个错误是怎么回事啊?
[he: command not found
方括号前后都要空格。

发表于 : 2007-02-02 23:13
kaixinlaohe
是的,楼上对了,谢谢!