Sato Sato -4 years ago 97
Linux Question

How to specify two variable in 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

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download