swqslwl
V2EX  ›  问与答

如何对一个工程里的所有文件进行 DOS/UNIX(CRLF/LF)转化

  •  
  •   swqslwl · Nov 18, 2018 · 3510 views
    This topic created in 2765 days ago, the information mentioned may be changed or developed.

    之前的项目文件换行格式全是 WINDOWS 的格式(CRLF),现在想全部转为 UNIX(LF)。在 IDE,notepad++中只能设置新创建的文件是 UNIX 格式或者修改单个文件的格式为 UNIX。难不成还要写个脚本去批量转化。?

    6 replies    2018-11-27 11:20:03 +08:00
    msg7086
        1
    msg7086  
       Nov 18, 2018
    dos2unix
    unix2dos
    AEANWspPmj3FUhDc
        2
    AEANWspPmj3FUhDc  
       Nov 18, 2018
    sed
    hjc4869
        3
    hjc4869  
       Nov 18, 2018 via iPhone   ❤️ 1
    find . -type f -print0 | xargs -0 dos2unix
    ant2017
        4
    ant2017  
       Nov 18, 2018
    dos2unix
    vi set ff=unix
    weyou
        5
    weyou  
       Nov 18, 2018 via Android
    find . -type f -exec dos2unix {} \;
    yanlaz
        6
    yanlaz  
       Nov 27, 2018
    wide find - replace ( Windows/DOS/Linux ):
    http://baiy.cn/utils/wfr/index.htm

    wfr test/*.php -s -r:"\r\n" -t:"\n" -encin:GB2312 -encout:utf-8
    //将 test 目录下所有 php 文件中的 crlf 替换成 lf,-s 包括子目录,-encin 输入文件编码,-encout 输出编码
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2765 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 11:56 · PVG 19:56 · LAX 04:56 · JFK 07:56
    ♥ Do have faith in what you're doing.