【问题标题】:Can I replace Unix line endings with Windows line endings on the commandline?我可以在命令行上用 Windows 行尾替换 Unix 行尾吗?
【发布时间】:2015-09-03 15:25:07
【问题描述】:

我正在摆弄hg log 命令来将反复无常的消息存储在一个文件中,例如(为了便于阅读而断行):

hg log --template "Rev. {rev} from {date|rfc822date}:
    \r\n--------------------------------------------
    \r\n\t{desc|strip|fill68|tabindent}\r\n\r\n\r\n" > hglog.txt

问题在于fill68 过滤器在 68 个字符后换行。理论上,也就是因为那些换行符是 Unix 换行符,在记事本中是不显示的。

有没有办法将\r\n 替换为\r\n,通过另一个命令传递hg log 的输出?

我希望在自动化的 VS 构建后脚本中运行此命令,因此我无法手动执行此操作。

【问题讨论】:

    标签: windows command-line line-endings


    【解决方案1】:

    您可以从 Windows 调用 MORE 命令,指定为 here

    hg log ... | more /p > hglog.txt
    

    【讨论】:

    • 我已经修改了解决方案
    • 但请注意,如果超过 65534 行文本,这将失败。
    最近更新 更多