Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Apr 2000 14:17:21 -0500
From:      Dan Nelson <dnelson@emsphone.com>
To:        Grigory Kljuchnikov <grn@ispras.ru>
Cc:        Arcady Genkin <a.genkin@utoronto.ca>, freebsd-questions@FreeBSD.ORG
Subject:   Re: A sed question
Message-ID:  <20000415141721.B29750@dan.emsphone.com>
In-Reply-To: <Pine.GSO.4.20.0004151047370.27653-100000@gate.ispras.ru>; from "Grigory Kljuchnikov" on Sat Apr 15 11:03:56 GMT 2000
References:  <878zygz9z0.fsf@tea.thpoon.com> <Pine.GSO.4.20.0004151047370.27653-100000@gate.ispras.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Apr 15), Grigory Kljuchnikov said:
> On 14 Apr 2000, Arcady Genkin wrote:
> > Dan Nelson <dnelson@emsphone.com> writes:
> > > Sure;  to specify more than one command, you need to pass them with the
> > > -e flag:
> > > sed -e 's/etc/etc/' -e 's/etc/etc/'
> > 
> > Oh, sorry, I meant something else. I meant two commands per _matched_
> > line, not per command line. Something like:
> > 
> > sed '/^Subject: / s/\[PHP3\]  *//g s/\[PHP4BETA] *//g'
> >                   ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
> >                   Command 1        Command 2
> > 
>
> There is only one command per line in sed or several commands
> per line with -e option.

After a bit more reading of the manpage, you can actually do what you
want.  There is only one *command* per line, but each command can have
several *functions*, and 's' is a function.  You can use a
function-list by separating them with newlines and putting { } around
the whole thing.  so

sed -e '/^Subject: /{ s/\[PHP3\]  *//g
s/\[PHP4BETA] *//g
}'

will do what you want.

-- 
	Dan Nelson
	dnelson@emsphone.com


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000415141721.B29750>