Skip to main content
added 408 characters in body
Source Link
glenn jackman
  • 88.5k
  • 16
  • 124
  • 179
source tmp.txt
export a b c
./child ...

Judging by your other question, you don't want to hardcode the variable names:

source tmp.txt
export $(cut -d= -f1 tmp.txt)

test it:

$ source tmp.txt
$ echo "$a $b $c"
123 hello world one more variable
$ perl -E 'say "@ENV{qw(a b c)}"'
  
$ export $(cut -d= -f1 tmp.txt)
$ perl -E 'say "@ENV{qw(a b c)}"'
123 hello world one more variable
source tmp.txt
export a b c
./child ...
source tmp.txt
export a b c
./child ...

Judging by your other question, you don't want to hardcode the variable names:

source tmp.txt
export $(cut -d= -f1 tmp.txt)

test it:

$ source tmp.txt
$ echo "$a $b $c"
123 hello world one more variable
$ perl -E 'say "@ENV{qw(a b c)}"'
  
$ export $(cut -d= -f1 tmp.txt)
$ perl -E 'say "@ENV{qw(a b c)}"'
123 hello world one more variable
Source Link
glenn jackman
  • 88.5k
  • 16
  • 124
  • 179

source tmp.txt
export a b c
./child ...