Skip to main content
1 of 3
Artefacto
  • 255
  • 2
  • 11

Use env with environment variables from file

Let's say I have a file (called e) with this content:

 a=3 b="5 6" 

How can I get each one to be interpreted as a separate argument to env? This one obviously doesn't work because of the space:

env $(cat e) ruby -e 'p ENV["a"]; p ENV["b"]' 

But neither does this one:

IFS=$'\n' env $(cat e) ruby -e 'p ENV["a"]; p ENV["b"]' 

And quoting $(cat e) will result in:

 "1\nb=2 3" nil 
Artefacto
  • 255
  • 2
  • 11