Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ucbvax!sdcsvax!allyn From: allyn@sdcsvax.UUCP Newsgroups: comp.unix.questions Subject: Re: sed - match newlines on input (the answer) Message-ID: <2842@sdcsvax.UCSD.EDU> Date: Wed, 11-Mar-87 14:23:30 EST Article-I.D.: sdcsvax.2842 Posted: Wed Mar 11 14:23:30 1987 Date-Received: Thu, 12-Mar-87 22:59:49 EST References: <570@hao.UCAR.EDU> <1987Mar10.180919.2869@gpu.utcs.toronto.edu> Organization: U.C. San Diego Lines: 32 In article <570@hao.UCAR.EDU>, bill@hao.UCAR.EDU (Bill Roberts) wants to use sed to match a pattern over multiple lines. the trick to sed is that you need to tell it when to join the lines before it can look for multiple line patterns. the N command is used for this. try this command: sed -f sedinput < inputfile with the "sedinput" file containing: /^one$/N /^one\ntwo$/N /^one\ntwo\nthree$/s/\n/, /g with an "inputfile" consisting of: zero one two three four it produces as output: zero one, two, three four -- From the virtual mind of Allyn Fratkin allyn@sdcsvax.ucsd.edu or EMU Project {ucbvax, decvax, ihnp4} U.C. San Diego !sdcsvax!allyn