我已經編寫了一個shell腳本,用於替換屬性文件中的某些屬性。但腳本運行後,在替換之前文件末尾沒有空行。使用echo和sed後缺少空行
file=my_file.properties
file_content=$(cat $file | sed "[email protected]=.*@[email protected]") #making a=b
file_content=$(echo "${file_content}" | sed "[email protected]=.*@[email protected]") #making x=y
echo "${file_content}" > $file
my_file.properties是一樣的東西
1)a=v
2)b=c
3)x=b
4)
注有空白行中end.These數字只是用於參考顯示空行
在問題中添加文件'my_file.properties'的一些示例內容。 – GurV