It is currently Mon, 08 Aug 2022 19:05:53 GMT

Author Message
 global variables in shell

 I am using sed/awk in a shell script, i want the user defined variables in
 awk/sed to be available in the shell from which awk/sed is invoked.


 Wed, 07 Apr 2004 15:35:43 GMT   
 global variables in shell

Perhaps you are doing this backwards?  Define the variable in the
shell script and pass it to the awk/sed script - if you can.

Otherwise you have to do what Gary suggested, or else create a string
that is passed to "eval" to set the value.

Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.

 Wed, 07 Apr 2004 19:47:09 GMT   
 global variables in shell
hmm. confused. here - the question suggest Vector wants to pass values
generated by the sed/awk process back to the the parent process - there is
no pipe from a child to a parent shell so exporting or sourcing variables
from the child wont make them visable to the parent. Is it not just a case
of stdout? i.e. cat xyz | awk '{print $1}' | read BLAH ???


 Wed, 07 Apr 2004 21:43:53 GMT   
 global variables in shell

If you want an awk or sed script to set variables in the parent shell,
you can write the script to print VARIABLE=value, and call it with
eval `script_name`

 Thu, 08 Apr 2004 03:33:58 GMT   
   [ 4 post ] 

Similar Threads

1. file contents into variable, or global variable from shell script

2. global shell environment variable

3. global shell variables

4. EXPORTING global variables...

5. global env. variables for tcsh

6. accessing a global variable

7. initialize the global variables in .so files

8. Unaligned access (bus error) on Solaris on global variable

9. Regarding locks and global variables

10. defining global environment variable

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software