space in variable

Hi,

How to check if a variable is having spaces or empty in shell scripts.

Please help

esham

For emptiness, man test says

       [-n] STRING
              the length of STRING is nonzero

       -z STRING
              the length of STRING is zero

There are other constructs which allow to set variables if they are not set et al..

       ${parameter:-word}
              Use  Default  Values.  If parameter is unset or null, the expan-
              sion of word is substituted.  Otherwise, the value of  parameter
              is substituted.
       ${parameter:=word}
              Assign  Default  Values.   If  parameter  is  unset or null, the
              expansion of word is assigned to parameter.  The value of param-
              eter  is  then  substituted.   Positional parameters and special
              parameters may not be assigned to in this way.
       ${parameter:?word}
              Display Error if Null or Unset.  If parameter is null or  unset,
              the  expansion  of  word (or a message to that effect if word is
              not present) is written to the standard error and the shell,  if
              it is not interactive, exits.  Otherwise, the value of parameter
              is substituted.
       ${parameter:+word}
              Use Alternate Value.  If parameter is null or unset, nothing  is
              substituted, otherwise the expansion of word is substituted.

The problem is that the variable is getting by reading each line from a file.
so some times, the variable reads the line where there is no charectors..

In this case, the variable takes as a line full of spaces..
I need to test if the variable is full of spaces..

please help

Look at this

sh-2.05b$ cat esham.txt
a
b

c
d
  
e
sh-2.05b$ while read line; do if [[ "$line" == "" ]] ; then echo "$line"; fi ; done < esham.txt 


sh-2.05b$ 

okay, it worked..
the problem was with some other iterations in the script..

thanks for ur help..
esham