Diff/Patch
I've got two files an old and a new file
File1: Code:
1,"red" Code:
1,"red" Code:
diff file1 file2 > file.diff However if I remove say line 3 from the second file, patch will not just give me all the differences of the File2. it will say Hunk 2 has failed and creates a rej file. Then the output from the patch will only have the line that was removed in it. But if I just change line 3 from blue to yellow, it's fine. anyone run into this problem, am i doing it all wrong from the start?? |
You're trying to use patch for something for which it was not intended.
The purpose of patch is to take as input two files: 1. the "older" version of a source file 2. the differences and produce the second file. For example, if you have file1 and file2, and they're large, but the differences between them are small, and you have clients who all have file1, you can send them the differences betweeen file1 and file2 (instead of all of file2) and they can create file2 on their own, using patch. file.diff, from my point of view, is already in a "nice text" format. But if file.diff is not in a sufficiently "nice text format" for you, that's fine. So how would it look differently to suit your needs? Maybe we can help you with that. |
thanks for the reply
Thanks for your help, I figured as much. I was just wondering if there was a way to use patch to do what I wanted. For those who in the future might look at this I've turned to sed.
try this command(to isolate the files to only the differences): Code:
sed -n -i '/\(^\)>/p' file.diff |
All times are GMT -5. The time now is 04:33 PM. |