in reply to incrementing the file

The problem with your approach is, that you have to check an ever growing number of files to determine the current version. The alternative is of course some kind of bookkeeping.

The simplest form I could think about is using a "output_$input_file_current" with a symlink to the real file "output_$input_file_$version". That way you only have to get the real file name of the symlink with readlink to determine the current maximum.

Replies are listed 'Best First'.
Re^2: incrementing the file
by nemesdani (Friar) on Feb 22, 2012 at 13:28 UTC
    Or create a last.txt, containing the name of the latest file. Your open it at the start of your program, overwrite and close it at the end. Not very elegant, but simple and robust.