[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] How to Increment a number in a config file?
- Subject: [ale] How to Increment a number in a config file?
- From: Gary at EdisonInfo.com (Gary MacKay)
- Date: Fri, 07 Sep 2001 11:06:14 -0400
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.