[NTLUG:Discuss] scope of variables in bash scripts

Richard Cobbe cobbe at directlink.net
Wed Aug 8 07:25:52 CDT 2001


Lo, on Tuesday, August 7, Fred James did write:

> My experience with sh (Bourne) is that a variables within a file have the
> scope of the file.  I am finding this is not true in bash, at least on
> Red Hat Linux 7.1 Variables assigned values within a while loop revert to
> there values, if any, before the loop was entered.
> 
> Am I missing something?  Is there a way to make a variable have the scope
> of the file?

My understanding was that all variables are essentialy global, as you say.
Could you post a short example of code that's not working as you expect?

Richard



More information about the Discuss mailing list