Hello all,

I am trying to come up (well, find actually) a simple method of incrementing a version number that I can call from a shell script. 'awk' was suggested to me by on of our developers, and I have found a bit of code that may work if I can figure out how to tweak it.

I hope that someone on this list will be willing to point me in the right direction with my pilfered script.

Our version numbers are in the format of x.x.x, and I wnat to increment the last number for each build at this point. I keep the last version number in a text file on the root of the build machine and I want to access it with some awk code, modify the last digit, and then pass it on to my other scripts.

Here is the code that I have found and been trying to work with:

BEGIN { FS="." }

first = $1
second = $2
third = $3

getline < "/version.txt"
{if ($1~"/+/") $1=first++
else if ($1~"/[0-9]+/") $1=$1
else $1=first}

{if ($2~"/+/") $2=second++
else if ($2~"/[0-9]+/") $2=$2
else $2=second}

{if ($3~"/+/") $3=third++
else if ($3~"/[0-9]+/") $3=$3
else $3=third}

{print $1"."$2"."$3}


Here is the file /version.txt:
8.0.100


And here is the file build.msk that is called from the command line:
*.*.+


And here is the output that I get when I run it:

$ awk -f incr.awk build.msk
*.*.+
*.*.+
*.*.+
8.0.100
*.*.+
$

I hope that this is not outside the scope of this mailing list, and that I am not being presumptuous in my question. I really appreciate ANY and all assistance in this matter.

Regards from the US,

Steve O'Sullivan
_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders

Reply via email to