I assume you want to bump the serial number, using the common date/revision formatting practice. So a bump should change the date to today's date, not just increment by one.
The following sets the serial number date to today's date + revision number. Note: it will fail after 99, as the general serial number update scheme with a date fails there anyway.
Code:
$ cat 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;
}' zonefile
$ bump_serial.sh
$ diff zonefile zonefile.bak
5c5
< 2008071000 ; serial
---
> 2006101902 ; serial
13c13
< 2008071000 ; se = serial number
---
> 2006101900 ; se = serial number
35c35
< 2008071035 ; se = serial number
---
> 2008071034 ; se = serial number
Use the perl statement inside your shell script. Replace "zonefile" with the variable or zone file you use in your script. It automatically creates a backup file too.