Quote:
|
Originally Posted by mirusko
is there a way how to export the variable from within the AWK command
|
The simple answer is no. The awk script is running as a subshell and there's no way to make a child process alter the environment of its parent.
Having said that, the awk process can create a file (say, /tmp/awk.env) with the content
where <x> is the new value. In your parent script, you then source the env file i.e.
Quote:
awk -v x=$X ...
. /tmp/awk.env
|
NOTE: By having the "export" in env file, it's not necessary to pass $X into the next awk call as it's now available in the parent's environment.
HTH
Jerry