What does colon (':') in bash variable resolution syntax mean?

I need to decode this assignment:

jvm_xmx=${jvm_xmx:-1024}
Asked By: user1065145

||

man page for bash:

${parameter:-word}
          Use Default Values.  If parameter is unset or null, the expansion of
          word is substituted.  Otherwise, the value of parameter is substituted.

So if jvm_xmx is already set to something, it is left unchanged.
If it is not already set to something, it is set to 1024.

Example:

$ echo $jvm_xmx

$ jvm_xmx=${jvm_xmx:-1024}
$ echo $jvm_xmx
1024
$ jvm_xmx=2048
$ jvm_xmx=${jvm_xmx:-1024}
$ echo $jvm_xmx
2048
$
Answered By: steve
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.