This will update the serials of all of your *.hosts files in the same directory that you executed the “updateserials” command in (aka `pwd`). This only updates serials that begin with the current year.

Enjoy!

#!/bin/bash
read −p "Are you sure you want to update `pwd`/*.hosts serial numbers to `date +%Y%m%d%H` (y/n)? "
if [ $REPLY == 'y' ];
then
  serial=`date +%Y%m%d%H`
  for file in $(ls `pwd`/*.hosts);
  do
    if [ −f $file ];
    then
      SEARCHYEAR=`date +%Y`
      OLD=`egrep −ho "$SEARCHYEAR[0−9]*" $file`
      NEW=$(($serial))
      sed −i "s/$OLD/$NEW/g" $file
      echo “fixed $file”
    fi
  done
fi