在unix中使用sdiff输出侧差的问题
我使用以下 sdiff 命令来获取两个文件的并排差异。列宽作为选项之一给出
sdiff -w170 /tmp/captureFile /tmp/referenceFile (或 diff -y )
如果我使用 -w 130 那么一些字符将被删除。即使在下一行,它们也不会出现在输出中。他们迷路了。
如果使用 -w 170,则由于左列中有多余的字符,右列会移动,并且由于屏幕宽度较小,因此在左列部分中看不到它的字符。
那么是否有任何选项可以不去掉字符,然后放在 sdiff 命令输出的同一列的下一行?
I am using the following sdiff command to get the side-by-side difference of two files. Column width is given as one of the options
sdiff -w170 /tmp/captureFile /tmp/referenceFile (or diff -y )
if i use -w 130 then some characters are stripped. They do not appear in output even on next line. They are lost.
And if -w 170 is used then due to extra characters in the left column, right column is shifted and so few of its characters are seen in the left column part due to screen width being smaller.
So is there any option not to strip off the characters and have then on the next line in the same column of the sdiff command output?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所看到的(显然)是相对于终端会话中的行长度的行截断(-w 130)或换行(-w 170)。我不相信有任何选择可以做你想做的事。我经常使用 sdiff &倾向于使用支持更改字体大小的终端/CLI。
将字体缩小到仍然可读的大小然后如果可能的话最大化窗口。
我所做的其他事情是在比较之前“折叠”两个文件以缩短行长度 - 取决于您使用的是 Linux 还是某些 Unix 发行版。但折叠应该在那里。
What you are seeing (obviously) is either line truncation (-w 130) or line wrap (-w 170) relative to the line length in your terminal session. I don't believe there is an option to do what you desire. I've used sdiff a lot & tend to use a terminal/CLI that supports changing font sizes.
Shrink the font to something still readable & then maximise the window if possible.
Something else I've done is to 'fold' the two files before comparison to have a shorter line length - depends if you're on Linux or some Unix distro. but fold should be there.
这是我为实现 @David Victor 的建议而编写的一个快速而肮脏的脚本:
Here is a quick and dirty script I wrote to implement @David Victor's suggestion :