如何在红帽Linux的文件,这是只有一行的内容的shell脚本设置猛砸变量,然后后添加一些文本。变量设置文件加上一些文字内容之后
例如:
echo "Version 1.2.3.4" > $TMPDIR/devver
env=dev
export ${env}_result="`cat $TMPDIR/${env}ver` (No response - version is from cache)"
echo $dev_result
我所要的输出是:
Version 1.2.3.4 (No response - version is from cache)
相反,我得到一个换行符后的版本,像这样:
Version 1.2.3.4
(No response - version is from cache)
谢谢!那样做了。感谢帮助。 – David
使用'printf'版本...''而不是'echo -n'版本...“'以实现更好的可移植性。在这种情况下并不重要,但这是一个好习惯。 –