Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/3/84; site teddy.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!talcott!panda!teddy!jpn From: jpn@teddy.UUCP Newsgroups: net.unix Subject: Re: Putting in newlines using sed Message-ID: <1688@teddy.UUCP> Date: Tue, 19-Nov-85 15:15:40 EST Article-I.D.: teddy.1688 Posted: Tue Nov 19 15:15:40 1985 Date-Received: Thu, 21-Nov-85 04:18:06 EST References: <376@bcsaic.UUCP> Reply-To: jpn@teddy.UUCP (John P. Nelson) Organization: GenRad, Inc., Concord, Mass. Lines: 23 >I have a process putting out lines that look something like this: > fjlkjf foo (a b c) jflkjf (jfkj) foo (x y a) fjjfj >I want to break up the line so that each "foo" followed by its >parenthesized list of arguments appears on a separate line. > >... So then I tried using to do the following: > s/foo/^Jfoo/g I had no problem, in csh: % sed 's/foo/\\ foo/g' in sh: $ sed 's/foo/\ > foo/g' (don't type the prompts) The trick is that sed will accept a newline in one of it's patterns if it is escaped with a backslash. The csh example needs a second backslash to tell the shell that the command line is not complete.