8

I need to decode this assignment:

jvm_xmx=${jvm_xmx:-1024}
2
  • where is the semicolon (;)?
    – Anthon
    Jul 8, 2015 at 8:51
  • 1
    Yep, seems like a duplicate. But original topic title makes it unsearchable. Jul 8, 2015 at 8:56

1 Answer 1

12

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
$
2
  • Thanks for answer. What does it mean when parameter is @ ? For example: ${@:10}
    – Atul
    Dec 5, 2019 at 11:06
  • 1
    Best to submit a whole new question for that, if the man page doesn't cover it for you.
    – steve
    Dec 6, 2019 at 9:53

Not the answer you're looking for? Browse other questions tagged .