По крайней мере, с GNU diff
, это кажется возможным с подходящими спецификаторами LFMT
(формат строки):
diff --new-line-format="replace line %-dn with:%c'\012'%L" --unchanged-line-format= --old-line-format= file1 file2
Протестировано с:
$ cat file1
Hello, this is a file.
It is pretty cool.
I wrote it in a text editor.
$ cat file2
Hello, this is a file.
It is kinda awesome.
I wrote it in a text editor.
$ diff --new-line-format="replace line %-dn with:%c'\012'%L" --unchanged-line-format= --old-line-format= file1 file2
replace line 2 with:
It is kinda awesome.