Yesterday, I had a problem. I had two files that were almost the same, but one of them had a few chunks of new data in it, and there were a couple of places where there were lines that only had a word or two changed in them. What I wanted was just the new data in the second file, and I didn’t care about the stuff that had just changed a bit.
Obviously, this sounded like a job for the
Unfortunately, I found the man page a little more difficult than normal to decipher and had to call upon the massively oversized brain of Ben Hawkes-Lewis to see if we could work out together how to do what I wanted. After a bit of fumbling, it turned out that we wanted to use the line group format options. Here’s what we came up with that solved my problem:
diff --new-group-format="%>" --old-group-format="" \ --changed-group-format="" --unchanged-group-format="" \ original.file file-with-extra-data.file
Hopefully this will be of use to someone else at some point too.
If you enjoyed this post, subscribe to The Code Train and read more when I write more.