in reply to Making a Diff from a partial change

(I'm assuming here that you don't have direct access to what the changed section looked like before: if you did, diffing that to the new version with plenty of context and applying it with patch is trivial.) If you can identify with certainty which part of the big file is the changed section, you can replace it with their changes. If you can't identify it with certainty, there isn't anything I see that will solve the problem for you unambiguously.

I think you are going to have to show what this data looks like to get help.

  • Comment on Re: Making a Diff from a partial change

Replies are listed 'Best First'.
Re^2: Making a Diff from a partial change
by gclef (Initiate) on Jun 08, 2005 at 18:59 UTC
    Thanks for the answer.
    I do have access to the previous version of both files (I'm storing all of this in a Subversion repository), but there may be other issues. The files are firewall configuration files, Cisco PIX, to be exact. So, they contain data like:
    access-list testing permit ip host 3.3.3.3 host 22.2.2.2
    access-list testing deny tcp object-group first host 4.4.4.4 eq 99
    
    or:
    object-group network first
      network-object host 9.9.9.9
    
    The thing is, I'm not sure I'm going to be able to get enough context to dump it straight to patch...some of these sections may be as short as one or two lines.

    What I'm trying to do here is give some users the ability to edit certain parts of device config, but limit their ability to edit other parts. (And, hopefully, apply some of these snippets to multiple devices, to make them all act the same.)

      if you're giving the user the ability to edit the section, then i assume you don't want to merge the results of the edits into the same section of the other file, but you merely want to replace the whole section. do this simply by having 1 or 2 other files which have all the text excluding that section, and join it with the edited section. i.e. new file will contain: constant text 1, edited new section, and then contant text 2
      the hardest line to type correctly is: stty erase ^H