简体   繁体   English

并排差异(-y):如何隐藏反向视频^ M(在行尾)?

[英]Side-by-side diff (-y) : how to hide the reverse-video ^M (at end-of-line)?

Problem 问题

I'm diffing files side-by-side ( -y ) on a GNU/Linux system: 我在GNU / Linux系统上并排( -y )比较文件:

$ diff -y file1 file2

but each end-of-line results in spurious ^M in reverse video ... one for the left line and one for the right line. 但是每行结束都会在反向视频中产生虚假的^M ...一个用于左行,一个用于右行。

Here's the version of diff I'm using: 这是我使用的diff版本:

diff (GNU diffutils) 3.3

EDIT: I forgot to mention I'm combining diff with less , and without | less 编辑:我忘了提一下我将diffless组合在一起,并且没有| less | less the ^M are not shown: | less^M未显示:

$ diff -y file1 file2 | less

Question

How can one avoid these reverse-video ^M chars to be produced by diff ? 如何避免diff产生这些反向视频^ M字符?


Note1: Without the -y I don't have the problem. 注意1:没有-y我就没有问题。 But I need this argument. 但是我需要这个论点。

Note2: I can't do unix2dos or dos2unix on any of the files because I must use them read-only. 注意2:我不能在任何文件上执行unix2dos或dos2unix,因为我必须以只读方式使用它们。

Note3: I have found similar questions that correspond to using diff with GIT, they didn't seem to be helpful in my case - I'm not using GIT here, just diff . 注意3:我发现类似的问题与将diff与GIT一起使用有关,它们似乎对我的情况没有帮助-我这里没有使用GIT,只是diff

尝试diff -y --strip-trailing-cr file1 file2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM