Preserve line endings

后端 未结 5 1440
耶瑟儿~
耶瑟儿~ 2020-12-02 11:53

I run sed to do some substitution on windows and I noticed that it automatically converts line endings to Unix (\\n). Is there an option to tell sed to use Windows line endi

5条回答
  •  长情又很酷
    2020-12-02 12:27

    I've found that sed-4.4.exe from https://github.com/mbuilov/sed-windows is pure win as it

    • uses windows CRLF line endings in default mode
    • preserves original line endings in -b mode
    • works correctly with in-place -i mode
    • also offers -z mode with \0 delimeters instead of \n which may be handy sometimes too

    See also list of sed options and list of all windows sed ports.

    Note that gnuwin32 sed 4.2.1 does corrupt line endings in -bi mode and doesn't have -z mode at all.

提交回复
热议问题