Easy question

Joseph S D Yao jsdy at cospo.osis.gov
Mon Nov 8 18:13:19 UTC 1999


> Actually, the command is sed.  Read the man page to find out how to
> replace one string with another:
> 
> sed -e 's/string1/string2/g'
> 
> To delete a line:
> 
> sed -e '/string/d'
> 
> etc, etc, etc . . . .

WARNING!

With all of these quite correct answers, one thing you must be wary of
is making sure that you match exactly those patterns that you want to
match!  E.g., if you say

	s/ns.a.org/ns2.a.org/

then this will replace not only ns.a.org, but also nsca.org and any
other ns?a?org pattern in your files!

Likewise, if you have hosts aleph and beth:

	@		IN NS		aleph.il.org.
	aleph.il.org.	IN A		10.18.0.1
	beth.il.org.	IN A		10.18.0.2

and you do:

	s/aleph.il.org/beth.il.org/

you end up with:

	@		IN NS		beth.il.org.
	beth.il.org.	IN A		10.18.0.1
	beth.il.org.	IN A		10.18.0.2

which is PROBABLY not what you wanted.

Grep first to find what your regular expression will match, then run
your 'perl', 'sed', 'awk', 'ex', or whatever script.

--
Joe Yao				jsdy at cospo.osis.gov - Joseph S. D. Yao
COSPO/OSIS Computer Support					EMT-B
-----------------------------------------------------------------------
This message is not an official statement of COSPO policies.


More information about the bind-users mailing list