powershell - 用Powershell用回车替换点

标签 powershell powershell-2.0

我有一个包含音乐歌词的 txt 文件。

我想用回车替换所有点,以提高可读性。

提前致谢。

最佳答案

(get-content file.txt) -replace '\.',"`n" | out-file newfile.txt

-replace 运算符使用正则表达式匹配,因此您需要转义点以使其匹配文字点。否则它将替换文件中的每个字符。

关于powershell - 用Powershell用回车替换点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9241473/

相关文章:

Powershell 使用管道中参数中的表达式 : "Move-Item : The given path' s format is not supported. "

PowerShell 启 Action 业增量

regex - 重命名文件时使用Move-Item,并使用正则表达式 “cleaning”文件名

powershell - 将项目添加到选择对象或格式表

powershell - 无法使用 Powershell 2.0 压缩文件

c# - 在 Powershell 中运行时与在 Visual Studio 中运行时的 HttpClient 并发行为不同

powershell - 如何阻止 Powershell 命令 `Get-NetFirewallRule` 抛出错误?

sql-server - 如何在 PowerShell 中使用 SMO 编写稍微改变的对象的脚本?

powershell - Get-Content命令对Powershell的理解

powershell - Powershell命令行抛出