a SED question

Maarten Litmaath maart at cs.vu.nl
Wed Dec 7 06:24:44 AEST 1988


slj at mtung.ATT.COM (S. Luke Jones) writes:
\Here is my problem:
\	I have a file composed of multi-line records.
\	Continuation lines begin with arbitrary white space.
\	I want to extract *some* of the records.

\for example:
\	In this file, the "Here is my..." and "for example" lines
\	begin multi-line records.  Suppose the records I want
\	are those that begin with an uppercase letter ("Here...")

\	sed -n -e '/^[A-Z]/,/^[^(spc)(tab)]/p' file

\	will print each such record, but would also get the "for..."
\	line of the second record.

\	sed -n -e '/^[A-Z]/,/^[(spc)(tab)]/p' file

\	will not get "for..." but will only get the first following
\	line that begins with white space.

#! /bin/sh

exec sed -n -e '
	/^[A-Z]/{
: loop
		p
		n
		/^[ 	]/b loop
		/^$/ b loop
	}
' $*
-- 
fcntl(fd, F_SETFL, FNDELAY):          |Maarten Litmaath @ VU Amsterdam:
      let's go weepin' in the corner! |maart at cs.vu.nl, mcvax!botter!maart



More information about the Comp.unix.questions mailing list