你如何搜索包含DOS行结束(CRLF)在Linux上使用grep的文件? [英] How do you search for files containing dos line endings (CRLF) with grep on Linux?

查看:126
本文介绍了你如何搜索包含DOS行结束(CRLF)在Linux上使用grep的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要搜索包含DOS行结束Linux上的grep的文件。事情是这样的:

的grep -IUr --color'\\ r \\ n'。

以上似乎匹配文字 RN 这是不是有什么是需要的。

此的输出将通过xargs的被输送到待办事项转换CRLF到LF像这样

 的grep -IUrl --color'^ M'。 | xargs的-ifile fromdos'文件'


解决方案

使用<大骨节病>控制 + <大骨节病> V ,<大骨节病>控制 + <大骨节病> M < /骨节病>输入文字回车符到grep的字符串。所以:

 的grep -IUr --color^ M

将工作 - 如果 ^ M 有文字CR,你输入我建议

如果你想要的文件列表中,您要添加的 -l <​​/ code>选项以及

I want to search for files containing dos line endings with grep on Linux. Something like this:

grep -IUr --color '\r\n' .

The above seems to match for literal rn which is not what is desired.

The output of this will be piped through xargs into todos to convert crlf to lf like this

grep -IUrl --color '^M' . | xargs -ifile fromdos 'file'

解决方案

Use Ctrl+V, Ctrl+M to enter a literal Carriage Return character into your grep string. So:

grep -IUr --color "^M"

will work - if the ^M there is a literal CR that you input as I suggested.

If you want the list of files, you want to add the -l option as well.

这篇关于你如何搜索包含DOS行结束(CRLF)在Linux上使用grep的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆