Hi all,
to check that a variable is not empty, I usually do:
if [ -z "$a" ]; then...
or
if [ -n "$a" ]; then...
what if I have a serie of variables and want to do the same test on all of them. How to do this in a single if statement?
thank you
Hi all,
to check that a variable is not empty, I usually do:
if [ -z "$a" ]; then...
or
if [ -n "$a" ]; then...
what if I have a serie of variables and want to do the same test on all of them. How to do this in a single if statement?
thank you
You can try using loops. For eg:
for i in <list of variables>
do
if [ -z $i ] then
do something;
else
do something;
done
HTH,
Regards,
Praveen