Linux diff 仅获取输出中的行号

Joh*_*mbo 2 linux diff

我想使用 linuxdiff命令来获得以下输出:

2,4c2,4
Run Code Online (Sandbox Code Playgroud)

我只想知道文件不同的行号。我不想要控制台上的实际行。

例如:

如果我执行以下命令: diff file1.txt file2.txt

我想要以下输出:

2,4c2,4

我不想要输出:

2,4c2,4
< I need to run the laundry.
< I need to wash the dog.
< I need to get the car detailed.
---
> I need to do the laundry.
> I need to wash the car.
> I need to get the dog detailed.
Run Code Online (Sandbox Code Playgroud)

我浏览了命令手册diff,但找不到任何可以让我实现我想要的选项。

Bar*_*mar 5

将其通过管道传输grep并仅显示以数字开头的行。

diff file1.txt file2.txt | grep '^[1-9]'
Run Code Online (Sandbox Code Playgroud)