I’m trying to put a variable into a line that gets put into a file.
The code looks like this:
echo "cd ~/Desktop/BukkitServer/" >> start.command
echo "java -Xms$ramM -Xmx$ramM -jar CraftBukkit.jar" >> start.command
chmod +x start.command
see how i put $ram in the second line? it ends up as
java -XmsM -XmxM -jar CraftBukkit.jar
how do i get it to put whatever $ram is in its proper place?
thanks 🙂
EDIT:
echo 'java -Xms{$ram}M -Xmx{$ram}M -jar craftbukkit.jar' >> start.command
produces java -Xms{$ram}M -Xmx{$ram}M -jar craftbukkit.jar
echo "java -Xms{$ram}M -Xmx{$ram}M -jar craftbukkit.jar" >> start.command
produces java -Xms{120}M -Xmx{120}M -jar craftbukkit.jar
$is used to mark a variable. With your command you are telling echo to putjava -Xmsfollowed by the content of the$ramMvariable in the file.You have to define a value for the variable
will produce
Note that you will have to use brackets
{}to delimit the variable name otherwise the shell will not know where your variable finishes.If you want to put a literal
$you will have to use single quotes (the shell will not interpret the content of the string).produces