On Tue, Mar 23, 2010 at 5:28 PM, Pushparaj Shetty <[email protected]> wrote:
> Hi,
> I wrote a shell script to check if string entered is null. The test -n
> option is not giving correct answer. It works fine with -z option.
>
>
> echo "enter a string"
> read a
> # test -n STRING
> # the length of STRING is nonzero
>
> if test -n $a; then echo "non zero"
> else echo "zero"
Try the following, it works.
----------
read a
if [ "$a" == "" ]; then
echo "Empty!"
fi
if [ -n "$a" ]; then
echo "non-zero"
fi
--------
--
l...@iitd - http://tinyurl.com/ycueutm
To unsubscribe from this group, send email to
iitdlug+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.