2017-01-24 12 views

回答

4

的Windows系統中使用回車+底線(\ r \ n)的是這樣的:

"b`r`nc" | out-file "c:\temp\a.txt" 

,如果你想要的東西,這對多。平臺工作試試這個:

'b' + [environment]::NewLine + 'c' | out-file "c:\temp\a.txt" 
3

你會偶爾需要使用新行結合一個「回車」,以獲得新的一行出現。試試這個:在回車

"b`r`nc" | out-file "a.txt" 

欲瞭解更多信息,可以read this on Stack Overflow.

-2

如果你用記事本++打開,你會看到換行符。此外,如果您運行

Get-Content a.txt 

你會看到線突破也有。

這裏的問題是編碼。對於這個工作:

"b`nc" | out-file a.txt -Encoding ascii 

這應該在記事本中正常打開。

+0

我測試了'' 「b'nc」| out-file a.txt -Encoding ascii''並發現當打開記事本時,換行符不存在。我確實在Notepad ++中看到它。 – Toomaja