I am writing up a script to automatically increment the serial number of
bind dns zone file , but I am running across issues doing in place
substitution with either sed or even perl for that matter. I can do
this easily in Linux but am having hard time doing so in openbsd. I
would like to search for the serial number , increment by one and then
save the file.
Any help...highly appreciated.
Thx.
Here is my code snippet:
#!/bin/sh
for file in $(ls /var/named/master/*.file);
do
if [ -f $file ];
then
OLD=`grep serial $file | awk '{print $1}'`
echo $OLD
NEW=$(($OLD + 1))
echo $NEW
*perl -p -i -e 's/$OLD/$NEW/' $file <--------------tried using
perl but still the file didn't change with the incremented serial number
sed 's/$OLD/$NEW/' $file <-----------------I know this will only
search and replace but how do I do in in-place so that the file itself
is modified.*
fi
done