使用 diff 和 -y 限制显示的字符数

using diff and -y limitation on number of characters displayed

我有这两个文件file1.txt:

$ cat file1.txt
I need to buy apples. I need to buy apples. I need to buy apples. I need to buy apples. I need to buy apples.
I need to run the laundry.
I need to wash the dog.
I need to get the car detailed.

和file2.txt:

$ cat file2.txt
I need to buy apples.
I need to do the laundry.
I need to wash the car.
I need to get the dog detailed.

我想使用 diff 命令查看文件中的输出差异,并使用 -y 选项显示它。

$ diff -y file1.txt file2.txt
I need to buy apples. I need to buy apples. I need to buy app | I need to buy apples.
I need to run the laundry.                                    | I need to do the laundry.
I need to wash the dog.                                       | I need to wash the car.
I need to get the car detailed.                               | I need to get the dog detailed.

不过好像有显示字数限制。注意来自 file1.txt.

的第 1 行

有没有办法可以增加此限制以便显示完整行内容?

$ echo I need to buy apples. I need to buy apples. I need to buy app | wc
      1      15      62

看来您需要指定宽度,试试这个:

diff --width=250 -y file1 file2

人差异:

-W NUM --width=NUM Output at most NUM (default 130) print columns.