Path: utzoo!attcan!uunet!wuarchive!udel!gvlv2!lock60!rdb1!root From: root@rdb1.UUCP (Robert Barrell) Newsgroups: comp.unix.questions Subject: Patching multiple files with same text Message-ID: <193@rdb1.UUCP> Date: 28 Mar 90 12:50:57 GMT Organization: Cody Computer Services Lines: 28 In a case where several files may have a given group of text lines, and that group of lines must be replaced in all files by another group of lines, is there any way to use patch, sed, or awk (sorry, I don't have perl) to perform such a patch? The problems I am encountering are: 1) The original text contains multiple lines, and ALL lines of the original must be replaced by the patch. 2) The patch is not the same length as the original text. 3) The original text is not always in the same relative position within each file, so "diff -e" scripts will only work for one file, due to the specific line numbers, and context diffs have the same problem because of the actual context (which may be different in all files). 4) Normal "diff" output, run through "patch" DOES work, but isn't specific enough about matching the ENTIRE original text, so if a similar group of lines appears in a file which doesn't contain the exact original, or if such appears BEFORE the original, a false patch can occur. I see, in the manuals, that sed has an "N" command for, supposedly, dealing with multiple lines, but I haven't quite figured-out how to use it yet (all the examples in the manuals are for single lines, and the description of "N" is rather terse. -- Robert Barrell | ...!cbmvax!gvlv2!lock60!rdb1!root | Cody Computer Services Milo's Meadow BBS | root@rdb1.canal.org | 55 East High Street login: nuucp or bbs |-----------------------------------| Pottstown, PA 19464 (215) 323-0497 | Business and Police Dept Software | (215) 326-7476