Hi,
How do I assign a value in if statement to global variable???
Real case:
sh> if [ "`echo "TEST TOAST"|awk '{myvar=$1}'`" ]
> then
> echo $myvar
> fi
TEST
This method does not work!!!!! Do you have any idea how to make this possible?
I know the other way is to do this is:
sh>myvar=`echo "TEST TOAST"|awk '{myvar=$1}'`
but is it possible to assign a variable in if statement to global variable either using awk/nawk or other unix command????
Please help, Thanks
Suhaimi
How do I assign a value in if statement to global variable???
Real case:
sh> if [ "`echo "TEST TOAST"|awk '{myvar=$1}'`" ]
> then
> echo $myvar
> fi
TEST
This method does not work!!!!! Do you have any idea how to make this possible?
I know the other way is to do this is:
sh>myvar=`echo "TEST TOAST"|awk '{myvar=$1}'`
but is it possible to assign a variable in if statement to global variable either using awk/nawk or other unix command????
Please help, Thanks
Suhaimi