Skip to content
Advertisement

How to specify two variables on bash command line?

For example, I can do this:

 ENV=dev ruby script.rb

But how can I do this?

USER=aa PASS=bb ruby script.rb

I cannot use this:

export USER=aa
export PASS=bb
ruby script.rb

I have to do it in one line

Advertisement

Answer

As far as I know, every Bourne shell allows any number of name=value pairs preceding the command to establish the environment. Bash certainly does.

$ foo=foo bar=bar env | grep -E 'foo|bar'
foo=foo
bar=bar
Advertisement