[PLUG] Re: [Q] shell scripting

Wil Cooley wcooley at nakedape.cc
Thu Dec 2 08:42:50 UTC 2004


On Wed, 01 Dec 2004 18:08:52 -0800, Roderick A. Anderson wrote:

> Grep has no option for "inplace editing".  In the back of my mind a
> thought floats around that I saw something many years ago (real years not
> Internet years :-) about how to do this.  I just can't nail it down.

No, but sed does.  If you want to remove lines matching a pattern, try
this:

sed -i -e '/PATTERN/d'

Of course, since you've got a list of patterns to match in
'no-imgate.lst', you'd probably rather use that than write out all the
patterns.  Something like this:

ARG=" -i "
for l in $(cat no-imgate.lst); do
  ARG="$ARG -e '/$l/d'"
done

sed $ARG transport.map

Wil
-- 
Wil Cooley                                 wcooley at nakedape.cc
Naked Ape Consulting                        http://nakedape.cc
* * * * Linux, UNIX, Networking and Security Solutions * * * *




More information about the PLUG mailing list