0

I have a server where I upload sometimes the new version of my software. For each upload, I have to incremente the build var contained in a file.ver, like #BUILD 345. Well, I cannot do this everytime manually, but I prefer a smart and fast solution, that increment the number of the version for each upload.

What's the easiest way? There is in bash a nice command to do that? Or a callback method written in C/C++?

user1056635
  • 785
  • 2
  • 9
  • 12

2 Answers2

1

You can use the command sed to replace strings in a file.

For example, if you have a file myfile with the following content:

// Some comments
// Version: #VERSION
// ...    

You can use the following command to replace the version number:

sed -i 's/#VERSION/123/g' myfile

The -i means inline, i.e. modify the file content.

Do not redirect the output of sed back to the same file, as in sed ... myfile > myfile as you will lose the file contents. See Redirect output from sed 's/c/d/' myFile to myFile

Result:

// Some comments
// Version: 123
// ...  

If you use Ant, this could be useful:

Use ANT to update build number and inject into source code

See also the following question related to version numbering (schemes):

Bumping version numbers for new releases in associated files (documentation)

Community
  • 1
  • 1
The Nail
  • 8,355
  • 2
  • 35
  • 48
0

If you want this to be easy you should use the IDE or makefile for this otherwise will probably forget it sometimes.

Depends on which system OS , ... your using, but most IDEs have this feature VisualStudio can do this or you create a small script in your makefile.

tripplet
  • 335
  • 1
  • 11