How to make sure a variable is not empty with the -z option ?
errorstatus="notnull"
if [ !-z $errorstatus ]
then
echo "string is not null"
fi
It returns the error :
./test: line 2: [: !-z: unary operator expected
How to make sure a variable is not empty with the -z option ?
errorstatus="notnull"
if [ !-z $errorstatus ]
then
echo "string is not null"
fi
It returns the error :
./test: line 2: [: !-z: unary operator expected
if [ !-z $errorstatus ] just put a space between ! and -z, like this: if [ ! -z $errorstatus ]