[ale] How to Increment a number in a config file?
Gary MacKay
Gary at EdisonInfo.com
Fri Sep 7 11:06:14 EDT 2001
I need to increment a number in a config file. The file contains:
{Rollout]
SerialNumber=67
All I want to do is increment the SerialNumber. I have gotten this far:
#!/bin/sh
SN=`cat sav.cfg | awk '/SerialNumber/ {split($1,a,"=");a[2]+=1;print
a[2]}'`
echo "[Rollout]" > test.cfg
echo "SerialNumber=$SN" >> test.cfg
This of course creates a whole new file, which then presents a problem
with ownership and perms. I could add a couple of lines to put the perms
back but... Is there a way to simply increment without messing up the
perms and such? This is a simple situation, but what if the file was a
huge one? Obviously I wouldn't want to make a whole new one each time.
TIA,
Gary
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list