我有一个参数如下:
parameter1=I am a line with spaces
我希望将此参数包含在另一个参数中,但用双引号括起来作为java程序的参数。
java myProgram command="The line was "I am a line with spaces" always."
但是当我这样做时:
java myProgram command="The line was $parameter1 always."
在java程序中我只获得该行的第一个标记,即“I”
所以为了包括空格,我做了:
java myProgram command="The line was "$parameter1" always."
显然现在我必须逃避报价。
所以我做了:
java myProgram command="The line was \"$parameter1\" always."
但这不起作用。
我是否错误地引用了双引号?
答案 0 :(得分:0)
您可能没有结束字符串
java myProgram command="The line was \"$parameter1\" always."
更改为
java myProgram command="The line was\"" + $parameter1 + "\" always."