一组(DOS) ANSI-C文本文件(点击此处下载)被复制到OSX笔记本电脑上。我希望确保CR\LF不会成为编译文件的障碍。崇高和vi似乎正确地显示了这些文件。
三个终结者是:
安装了dos2unix:
brew install dos2unix尝试处理ANSI文件返回错误:
$ dos2unix *.h
dos2unix: Binary symbol 0x1A found at line 75
dos2unix: Skipping binary file error.h
dos2unix: Binary symbol 0x1A found at line 156
dos2unix: Skipping binary file random.h
dos2unix: Binary symbol 0x1A found at line 49
dos2unix: Skipping binary file resource.h
dos2unix: Binary symbol 0x1A found at line 107
dos2unix: Skipping binary file results.h
dos2unix: Binary symbol 0x1A found at line 261
dos2unix: Skipping binary file sim_lib.h
dos2unix: Binary symbol 0x1A found at line 27
dos2unix: Skipping binary file stats.h.c文件
$ dos2unix *.c
dos2unix: Binary symbol 0x1A found at line 110
dos2unix: Skipping binary file error.c
dos2unix: Binary symbol 0x1A found at line 780
dos2unix: Skipping binary file random.c
dos2unix: Binary symbol 0x1A found at line 79
dos2unix: Skipping binary file resource.c
dos2unix: Binary symbol 0x1A found at line 582
dos2unix: Skipping binary file results.c
dos2unix: Binary symbol 0x1A found at line 1755
dos2unix: Skipping binary file sim_lib.c
dos2unix: Binary symbol 0x1A found at line 102
dos2unix: Skipping binary file stats.c要确保正确的终止符被应用,需要采取哪些步骤?
如何才能可视化(核实)哪个终结者正在参与?(CR \ LF \ CRLF)
-f (force)标志将忽略0x1A并处理该文件。递归查找.c文件:
user@hostname:~/csim$ find . -name '*.c' | xargs dos2unix -f发布于 2020-01-27 23:42:28
下面是一个简单的测试:
~/tmp$ printf "\x1Aabc\r\n" > test
~/tmp$ od -a test
0000000 sub a b c cr nl
0000006
~/tmp$ dos2unix test
dos2unix: Binary symbol 0x1A found at line 1
dos2unix: Skipping binary file test
~/tmp$ dos2unix -f test
dos2unix: converting file test to Unix format...
~/tmp$ od -a test
0000000 sub a b c nl
0000005。使用dos2unix -f强制转换
。使用od -a查看二进制文件
。麦克上的终结者也是LF。
https://unix.stackexchange.com/questions/564458
复制相似问题