用新行替换一个字符 [英] Replace a character with new line
本文介绍了用新行替换一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Powershell 版本 4.Windows 7
我想用文本文件中的新行替换 ,
.我尝试了下面的脚本
I wanted to replace ,
with new lines in a text file. I tried the script below
(Get-Content C:\Test\test.txt).Replace(',','`n') | Set-Content C:\Test\testv2.txt
但是当我看到输出文件时,我看到 ,
替换为 '`n' 而不是换行.
but when I see the output file I see ,
replaced with '`n' instead of new line.
我也试过双引号而不是单引号.
I also tried double quotes instead of single.
Replace(',',"`n")
推荐答案
试试这个:
[IO.File]::ReadAllText(C:\Test\test.txt) -replace ',',"`r`n" | Out-File C:\Test\testv2.txt
附言抱歉,现在没时间解释.
P.S. Sorry that don't have time to explain it, now.
这篇关于用新行替换一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文