Help with sed script?

Kevin D. Clark kclark at elbrysnetworks.com
Tue Sep 5 16:46:02 EDT 2006


Michael ODonnell writes:

> I'm trying to use sed to rewrite lines in a config file that
> have a target string 'xyz' in them surrounded by whitespace
> and which are NOT commented out with a hash sign and which
> may or may not have leading whitespace.  This expression:

How about:

  sed -r -e '/^[[:space:]]*\<xyz\>/{s/^.*$/REWRITTEN/}'


This solution is nice too:

  perl -pe 's/^\s*\bxyz\b.*/REWRITTEN/'

Regards,

--kevin
-- 
GnuPG ID: B280F24E                     And the madness of the crowd
alumni.unh.edu!kdc                     Is an epileptic fit
                                       -- Tom Waits




More information about the gnhlug-discuss mailing list