![]() |
using sed to change zone file serial number
Hi Guys...
I have just started to learn about 'sed' and find it very useful. I wonder if it is possible to change the serial number in DNS zone files enblock. eg. Change: 2010121901()or whatever the number is) To: 2011121901 In perl there is a command: Code:
perl -i -p -e 's/\d\d\d\d\d\d\d\d\d\d/2011121901/' *Has anybody any ideas ??? John C |
The perl command could be shortened to:
Code:
perl -i -pe 's/\d{10}/2011121901/' *Code:
sed -i -e 's/[0-9]\{10\}/2011121901/' *Both commands search for 10 digits numbers, maybe you could restrict the research more |
sed or not, I find that approach somewhat risque ... while it
doesn't make too much sense there's still nothing to stop a user from defining hostnames that consist of 10 digits - I don't think you'd want ALL of those to be equal to your new serial? That said: Code:
sed -r -e '/^[\t ]+[0-9]{10}[\t ]*;[\t ]*serial/ s/[0-9]{10}/2011121901/' *just for sanitys sake. And of course bear in mind that if you change the file for the 2nd time on the same day the tailing two digits need to be incremented ... thought I'd chuck that in for good measure. ;} Cheers, Tink P.S.: Beat too it :} ... that's what happens if you start responding and walk away. =o) |
Hi Cedrik..
Thank you so much for your extremely quick reply. I have tested both these commands and found that they work fine for me. This is going to save me a lot of time when I transfer all my domains to a new server. THANK YOU. John C |
Hi Tinkster...
Quote:
I tried man pages and google and didn't get anywhere near an answer. That was when I decided to put a post on the forum. I can only spend so much time looking and getting nowhere |
Quote:
Whether or not you chose to take my SIGNATURE personally is entirely up to you my friend ... =o) Cheers, Tink |
Now, if it were me, I would as a matter of principle always write such code to read one file as input and to write another copy of that file as output ... then to do some renaming so that when the program finished it had the "new" copy in-place and one or more "backup" copies nearby.
:eek: Code:
set_my_speed( miles_per_hour(100) ); |
| All times are GMT -5. The time now is 12:12 PM. |