IRCBrasil

Well-Known Member
Jul 22, 2004
93
0
156
Hi,

I have this situation: I need a mass change on all dns zones. All lines equal this:

domain.com. 3600 IN TXT "v=spf1 a mx ptr ip4:11.22.33.44 a:ns1.domain.com a:ns2.domain.com -all"

need be changed to:

domain.com. 3600 IN TXT "v=spf1 a mx ptr ip4:55.66.77.88 a:ns1.domain.com a:ns2.domain.com -all"

Some sugestion?

Since now, tanks for any help.
 

freedog96150

Well-Known Member
Mar 25, 2005
68
0
156
Nevada, USA
A very quick and crude way to make bulk changes in RH based systems is to use the replace command. You can find help for the replace command by typing
Code:
replace -v
at the prompt. Here is a sample command to change your files in one swoop. Keep in mind that this command is indiscriminate, so it will replace ALL instances of the match with the replacement.
Code:
[root@mybox ~]# replace ip4:11.22.33.44 ip4:55.66.77.88 -- /dir/with/files/*
If your distro does not have replace, then use my personal favorite utility - sed. This is not as hard are most people think and is very powerful (well beyond my simple example below). There is plenty of help on the web at your fingertips with a simple google search. So now to the nitty-gritty:

Code:
[root@mybox ~]# sed -e 's/ip4:11.22.33.44/ip4:55.66.77.88/g' /dir/with/files/*
Simply put this scripts tell sed to '(s)ubstitute/this string/with this string/(g)lobally' in these files

Hope this helps. Be careful and remember that it is always a good idea to make a copy of the files to a new directory and experiment on the copy first. Once the desired results are achieved, then replace your working copies.