cnsystem 网络 Linux 操作系统 javascript cnsystem的博客

Shell 字符串比较

#! /bin/sh

str1="loving you too"
str2='loving you'
if [ str1=str2 ]
then
echo "true"
else
echo "false"
fi
if [ "$str1"="$str2" ]
then
echo "true"
else
echo "false"
fi
if [ \$str1=\$str2 ]
then
echo "true"
else
echo "false"
fi
echo $str1 #loving you too
echo $str2 #loving you
exit 0

为什么都是true呢?

who can tell me?

posted @ 2011-10-25 20:44  CNSystem  阅读(518)  评论(3编辑  收藏  举报
cnsystem 网络 Linux 操作系统 javascript cnsystem的博客