如何确定文件的行尾 [英] How to determine the line ending of a file
本文介绍了如何确定文件的行尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一堆(数百个)文件应该以 Unix 行结尾.我强烈怀疑其中一些有 Windows 行结尾,我想以编程方式找出哪些是.
I have a bunch (hundreds) of files that are supposed to have Unix line endings. I strongly suspect that some of them have Windows line endings, and I want to programmatically figure out which ones do.
我知道我可以在脚本中运行
I know I can just run
flip -u
或类似的东西来转换所有内容,但我希望能够识别那些需要首先更改的文件.
or something similar in a script to convert everything, but I want to be able to identify those files that need changing first.
推荐答案
你可以使用 grep
egrep -l $'\r'\$ *
这篇关于如何确定文件的行尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文