OT: setting variables
Mike Erdely
mike at erdelynet.com
Wed Mar 11 03:58:15 CET 2009
On Wed, Mar 11, 2009 at 02:37:05AM +0000, Bryan wrote:
> now, the text file creates text, and I've used the "tail - grep - cut
> - cut" command on the command line and was able to get the data I
> needed. Also on the command line, I can export the variable (I do it
> all the time with PKG_PATH). When I run the script, the crop.txt is
> created, and the variable prints out $CROP, but after the script ends,
> I attempt to "echo $CROP" and the variable is empty...
>
> Is there something I'm missing? Or is there nothing wrong, and the
> script (while running) knows the value of $CROP, value of $CROP is
> dropped once the script terminates.
When the script is run, a new sub-shell is created and the variable is
set within that sub-shell. When the script exits, so does the variable.
If you want the variable to be set in the current shell's environment,
you could run: . ./script
This will execute the commands inside the current shell.
-ME
More information about the Openbsd-newbies
mailing list