我想使用 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
,但找不到任何可以让我实现我想要的选项。
将其通过管道传输grep
并仅显示以数字开头的行。
diff file1.txt file2.txt | grep '^[1-9]'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4400 次 |
最近记录: |