now I get the value of $var but when it is out of the while loop
it does not return me a value.
I tried using typeset,still the same issue
So the question is when i set a value for a variable and export it in a while loop the value of the variable is not returned after I echo it out of the loop.
Thanks in advance
Syed
P.S : It can be done a one-liner; but my requirement it to run it through an array so I need the while loop.
An "export" statement only works in the current shell or subshell and makes a variable available to any scripts you call. It does not make the variable available to the parent shell. In this case the "export" statement is surplus in both examples. I can't explain in this context why "while" created a subshell when "for" did not.
cfajohnson may know better.