Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a bash script called "startserver.sh". I call it from another file like this: sudo sh /opt/startserver.sh 400

I want to use the parameter "400" in startserver.sh like this: java -Xmx400MB -jar craftbukkit-beta.jar

I tried: java -Xmx"$(printf "$1")"MB -jar craftbukkit-beta.jar, but it did not worked.

Of course, without option -Xmx....MB it works perfectly.

Any ideas?

Thanks in advance.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Curly braces after the dollar sign allow you to expand a variable without putting spaces around it:

java -Xmx${1}MB -jar craftbukkit-beta.jar
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.