【发布时间】:2010-11-25 13:39:33
【问题描述】:
我正在尝试让if 语句在Bash 中工作(使用Ubuntu):
#!/bin/bash
s1="hi"
s2="hi"
if ["$s1" == "$s2"]
then
echo match
fi
我尝试了各种形式的if 语句,使用[["$s1" == "$s2"]],带和不带引号,使用=、== 和-eq,但我仍然收到以下错误:
[嗨:找不到命令
我查看了各种网站和教程并复制了它们,但它不起作用 - 我做错了什么?
最后,我想说如果$s1 包含$s2,那我该怎么做呢?
我只是计算了一下空格...:/我怎么说包含?
我试过了
if [[ "$s1" == "*$s2*" ]]
但是没有用。
【问题讨论】:
标签: bash if-statement scripting