[英]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.