0

how do I set an environment variable in my .profile file that takes into account if the variable exists and appends to it?

To explain:

I want to do

export ANT_OPTS=-Dparam=value 

but if the ANT_OPTS already exists I want to append to it.

I want to do something similar to

set ANT_OPTS=%ANT_OPTS% -Dparam=value 

in Windows.

How do I create it or append to it if it already exists?

1 Answer 1

2

Try

export ANT_OPTS="$ANT_OPTS -Dparam=value"

1
  • it worked like a charm. I was trying export ANT_OPTS=$ANT_OPTS -Dparam=value but it didn't work. It didn't occur to me to also add the quotes. Thanks!
    – user12345
    Aug 26, 2010 at 7:27

You must log in to answer this question.