Regular Expression For Space

Hi all,

I want a regular expression that will check for the space.

I mean, it should accept everything but no space should be there in the variable.

e.g. var1="aaaa" >>> OK

var2='aaa vv' >> Not OK

So it should not validate the second variable.

Please help.

Thanks in Advance.
Amit

Use grep and check the error code "$?".

Regards

newer versions of grep (and sed, and other ass well) have the [:whitespace:] "thingy" (sorry, i cant recall the name of that construction)

so you could use grep to filter out spaces (egrep -v [:whitespace:] )
or use the a negation in the regexp (and i cant fin how to negate)

It isn't necessary to use a POSIX character class for a space:

echo "$var" | grep ' ' &>/dev/null
if [ $? -eq 1 ]; then
  echo "Not OK"
fi

Regards