This site uses advanced css techniques
Those who manage BIND nameservers are familiar with having to (and occasionally forgetting to) increment the serial number found in the SOA resource record at the top of the file. These SOA records look like:
@ IN SOA linux.unixwiz.net. steve.unixwiz.net. ( 69 ; serial 7200 ; Refresh 1 hour 3600 ; Retry 1 hour 604800 ; Expire 1 week 86400 ) ; Minimum 1 day
It's obvious that the next serialnumber is 70, and this is straightforward enough. But other administrators use the convention where the serial number includes the date of last edit (along with an intra-day sequence number):
@ IN SOA linux.unixwiz.net. steve.unixwiz.net. ( 2002112902 ; serial 7200 ; Refresh 1 hour 3600 ; Retry 1 hour 604800 ; Expire 1 week 86400 ) ; Minimum 1 day
To automate this, we wrote a very simple tool in perl that can be used from within the vi editor to increment the serial number in place, in a method-appropriate way.
We rely on the vi command of "filter-line-through": this is done by moving the cursor to the line of interest, and typing
The first ! is vi's "filter" command, and the ! that follows (because it's a repeat of the command) means it applies to the current line. incsoa is the UNIX-level command whose output replaces the line that appears in the file.
This program is smart about doing the increment: it notices that the serial number is in the YYYYMMDD format and either increments it (for an intraday increment) or replaces it with today's date. The replacement leaves all existing comments and whitespace alone.
To install this program, simply copy it to a convenient place in the system $PATH (say, /usr/local/bin) after removing the .txt extension. Make sure that your perl interpreter is found in the same place as suggested by the first line of the file, and make it executable. It takes no command-line parameters.
It may be possible to use this program from other editors such as emacs, but we've not given it any thought.
This program is written in perl, but the filename as found on the webserver is .txt to allow easier saving.