I need to increment named serial and I want to do it with sed. I've done it like this:
echo 2015092315 | gsed s/20[0-9][0-9][0-9][0-9]*/`date +%Y%m%d%H`/g
But then I realized that updates to zone file might happen more than once an hour and this above will not be enough.
Now I want to increment the serial by 1. How to do that? I came up with a:
gsed 's/20[0-9][0-9][0-9][0-9]*/expr & + 1/e'
which does work but it deletes the beginning of line (spaces) and the end of the line (comment), and gives error about a comment (sh: serial: not found) which I do not want.