On Fri, Apr 04, 2008 at 01:07:10AM -0700, Parvinder Bhasin wrote: > 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
Works for me. Try just the perl -pi -e 's/foo/bar/' testfile.txt on its own first. You might have a problem with the substitution pattern. Check the timestamps of the target file before and after. It should work. What is the * doing before perl? > perl but still the file didn't change with the incremented serial number > sed 's/$OLD/$NEW/' $file <-----------------I know this will only sed can not do it. perl can. > search and replace but how do I do in in-place so that the file itself > is modified.* > fi > done -- / Raimo Niskanen, Erlang/OTP, Ericsson AB