Putting in newlines using sed

Ron Thompson rt at cpsc53.UUCP
Mon Nov 18 12:33:26 AEST 1985


> 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.  I don't
> care what happens to the other "words;" they are eliminated in
> later processing.
> 
> As far as I can tell, there's no 
> way of writing the s/... line above with a *real* linefeed in place of the ^
> and J.
> 

With Sys V just type the following from the shell:

sed 's/foo/\
> foo/g' filename

The backslash escapes your newline producing a series of lines
all that begin with foo.


-- 
  Ron Thompson		AT&T Information Systems	Customer Programming  
  ..akgua!cpsc53!rt 	Atlanta, Georgia		Services Center	      
  (404) 982-4524        (Opinions expressed are mine alone.)



More information about the Comp.unix mailing list