Hey all, I am trying to write a script that will take a mask in, such as
+.*.*.*
which will run on a text file containing only a version number, like:
1.0.0.0
and will update the text file according to the mask. The output should be
2.0.0.0.
AND IT IS. But putting the result on the screen is the farthest I've gotten. I don't know how to write this back into a file. I'm sure its simple. I am totally new to the command line.
version.awk:
BEGIN { FS="." }
first = $1
second = $2
third = $3
fourth = $4
fifth = $5
getline < "cmdver.txt"
{if ($1=="+") $1=first + 1
else if ($1=="[0-9]*") $1=$1
else $1 = first}
{if ($2=="+") $2=second+1
else if ($2=="[0-9]*") $2=$2
else $2 = second}
{if ($3=="+") $3=third+1
else if ($3=="[0-9]*") $3=$3
else $3 = third}
{if ($4=="+") $4=fourth+1
else if ($4=="[0-9]*") $4=$4
else $4 = fourth}
{print $1,".",$2,".",$3,".",$4}
version.bat:
Echo %1 > cmdver.txt
gawk -f version.awk %2
Any tips? And a very minor problem at the moment; if a number is entered instead of a star or +, the output doesn't change, and it is supposed to.
+.*.*.*
which will run on a text file containing only a version number, like:
1.0.0.0
and will update the text file according to the mask. The output should be
2.0.0.0.
AND IT IS. But putting the result on the screen is the farthest I've gotten. I don't know how to write this back into a file. I'm sure its simple. I am totally new to the command line.
version.awk:
BEGIN { FS="." }
first = $1
second = $2
third = $3
fourth = $4
fifth = $5
getline < "cmdver.txt"
{if ($1=="+") $1=first + 1
else if ($1=="[0-9]*") $1=$1
else $1 = first}
{if ($2=="+") $2=second+1
else if ($2=="[0-9]*") $2=$2
else $2 = second}
{if ($3=="+") $3=third+1
else if ($3=="[0-9]*") $3=$3
else $3 = third}
{if ($4=="+") $4=fourth+1
else if ($4=="[0-9]*") $4=$4
else $4 = fourth}
{print $1,".",$2,".",$3,".",$4}
version.bat:
Echo %1 > cmdver.txt
gawk -f version.awk %2
Any tips? And a very minor problem at the moment; if a number is entered instead of a star or +, the output doesn't change, and it is supposed to.