I wanted to compile my program and I wanted to know how many times I have compiled it.
How do I make a .sh file to do that? (I'm using mac, is it .sh file?)
|
Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.
|
It seems odd to be using a .sh script for build automation. There are several other tools (make, ant, maven) which are much better suited to doing builds and tracking build numbers. Using one of the more industry standard tools for build automation will, in the long run, make for something that is easier to maintain both for yourself and others. |
|||||
|
|
The following script will do just that in a file declared in the "file" variable:
At the end of it you can add the command to invoke the build for your project. |
|||
|
|
|
Store in a file how many times you have compiled. |
|||
|
|
|
Its quite Simple, Make a counter in the begining of your script and save the last value in a text file. For example : Read the value first from the file, like
counter = counter= Store this counter value in a fileecho $counter > /tmp/SomeDIR/LOGS.txt |
|||
|
|
|
If you want to store a state variable that remembers how many times an action took place, the best way to do it would be in an external file that is separate from the script file. So you could read and write to this file, every time you ran the program. The basic pseudocode would be as follows:
|
|||
|
|