【问题标题】:Cygwin and tr settingsCygwin 和 tr 设置
【发布时间】:2014-05-05 11:27:40
【问题描述】:

我通过 Cygwin 使用 Unix 实用程序 tr。我想替换 '\ n' 的非字母字符,但 tr 也将重音字符识别为非字母字符(ěščřžýáíé -> \ n)。我可以更改此设置吗?

谢谢。

【问题讨论】:

    标签: unix cygwin tr


    【解决方案1】:

    应该这样做

    tr -c '[:cntrl:][:print:]' '\n'
    

    根据区域设置,您可能需要

    LANG= tr -c '[:cntrl:][:print:]' '\n'
    

    或者这个

    tr -c $'\x01-\x7e' '\n'
    

    【讨论】:

    • $ tr -c '[:cntrl:][:print:]' '\n' < input.txt > output.txt tr: when translating with complemented character classes, string2 must map all characters in the domain to one 这是输入:Bývalý technik amerických tajných služeb Edward Snowden rozšířil svou žádost o azyl na dvacítku dalších zemí。
    • 是的,它有效,我还有一些其他问题,但这对我有很大帮助。
    猜你喜欢
    • 2018-10-26
    • 1970-01-01
    • 2013-08-10
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多