-
Website
http://www.tech-recipes.com/ -
Original page
http://www.tech-recipes.com/rx/209/bournebash-shell-scripts-string-comparison/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
davak
83 comments · 1 points
-
danishbacker
9 comments · 1 points
-
flexinfo
11 comments · 1 points
-
bej
4 comments · 1 points
-
dimithri
5 comments · 1 points
-
-
Popular Threads
-
Windows 7: How to Prevent the Mouse from Waking your PC
1 week ago · 2 comments
-
Outlook 2010: Turn Off Attachment Preview
2 weeks ago · 2 comments
-
Gmail: How to Send SMS Messages Without Using Email
3 weeks ago · 2 comments
-
Thunderbird 3: How to Download Images Automatically
2 weeks ago · 1 comment
-
Windows 7 – Prevent Live Messenger from Opening at Start Up
2 weeks ago · 1 comment
-
Windows 7: How to Prevent the Mouse from Waking your PC
if [ -z $var ];then
echo null
fi
if [ -z "$var" ];then
echo null
fi
Best Regards,
Kibokina
if [ $var == "" ] ......
because if the variable $var is empty the test is
if [ == "" ] and gives an error
you are obliged to quote the var :
if [ "$var" == "" ] ...
Sergio
s1 = "as"
s2 = "bs"
if test $s1 == $s2
then
echo s1 and s2 are equal
fi
test: 40: ==: unexpected operator
then
echo not the same
fi
if [ "X${VAR}" = "X" ]; then
echo "Empty string"
fi
Testing for equality follows the same logic but without X.