adding diff output to the original file
Hi,
I am trying to figure out how I can add the output from a diff (or perhaps some other command) back to the original file on the next line from where it was different. For example, if file A contains: a b c d and file B contains: b c c d It would end up as: a b b c c d The different lines from file B were added after the original line in file A. Anyone know how I can do this? Let me know if this isn't clear enough. Thanks! |
I created two files---"dif" and "dif1"
Code:
[mherring@herring_desk play]$ more dif |
Quote:
one two three four five six In other words, it would take the different line, and place it after the original line. |
Sorry--I missed that detail. It seems you are looking for something that "synchronizes" one file to another. My knowledge of these is essentially zero----have you looked at something like rsync?
In your modification of my simple example, the data simply gets interleaved---would that always be the rule? eg, what would be the result in this case?: file 1: one three four five six file 2: two four five six seven |
Quote:
I want it to do essentially the same thing as a diff command, but instead of outputting just the different lines, I want it to add those different lines back to the original file, after the line that they differ from. Make sense? |
If your files have equal numbers of lines then perhaps this meets your requirements.
Code:
bash-4.2$ cat fileA |
Quote:
Thanks again! |
All times are GMT -5. The time now is 09:22 AM. |