DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Change SOA Serial In DNS Hosts File Config

05.14.2009
| 4406 views |
  • submit to reddit
        
# bump_serial.sh
#!/bin/bash

perl -i.bak -pe 'BEGIN {chomp ($now=qx/date +%Y%m%d/)};
    /(\d{8})(\d{2})/ and do {
        $serial = ($1 eq $now ? $2+1 : 0);
        s/\d{8}(\d{2})/sprintf "%8d%02d",$now,$serial/e;
}' name.hosts