[英]linux shell leave spaces in variable
我有一个shell脚本,该脚本应该创建一个文件并在其上填充两行(以使其变得简单)。
echo -e "#-*- coding: utf-8 -*-
var1 = ''" > file1.py
确实可以,但是当我尝试将file1.py内容放入变量中时,它会缩短空间并仅保留一个空间。
content="#-*- coding: utf-8 -*-
var1 = ''"
echo -e $content > file1.py
:( 请帮忙
在执行之前,命令被解析为:
echo -e this is what is inside the content variable > file1.py
因此,您只需要再次引用它:
echo -e "$content" > file1.py
结果是:
echo -e "this is what is inside the content variable" > file1.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.