George V. Reilly

Diffing a fragment of a file

A while back, I had extracted some code out of a large file into a separate file and made some mod­i­fi­ca­tions. I wanted to check that the dif­fer­ences were minimal. Let’s say that the extracted code had been between lines 123 and 456 of large_old_­file.

diff -u <(sed -n '123,456p;457q' large_old_file) new_file

What’s happening here?

A similar example: Diff a Trans­formed File.

BTW, these days, I usually use delta for diffing at the command line, especially with Git.

blog comments powered by Disqus
40 Years of Programming » « Ulysses at 100