Linux 尝试比较shell脚本中的字符串时出错
我的脚本中包含以下内容:Linux 尝试比较shell脚本中的字符串时出错,linux,shell,Linux,Shell,我的脚本中包含以下内容: fw=$2 if [ "$fw" == "zf" ] then public_dir=$dir/current/public else public_dir=$dir/current fi 但我在运行时遇到以下错误: ./generatevhost.sh: 15: [: zf: unexpected operator 我有一些查找页面解释了如何比较字符串,它们是这样描述的。我做错了什么?我相信您没有使用BASH或ksh。通过将=替换为=,尝试此if条件: f
fw=$2
if [ "$fw" == "zf" ]
then
public_dir=$dir/current/public
else
public_dir=$dir/current
fi
但我在运行时遇到以下错误:
./generatevhost.sh: 15: [: zf: unexpected operator
我有一些查找页面解释了如何比较字符串,它们是这样描述的。我做错了什么?我相信您没有使用BASH或ksh。通过将
=
替换为=
,尝试此if条件:
fw="$2"
if [ "$fw" = "zf" ]
then
public_dir=$dir/current/public
else
public_dir=$dir/current
fi