I can use
mktemp(1) within a shell script to make a temporary file in a directory with a suitable suffix & prefix.
Is there a command that, given a pattern (e.g.
NN-output.log) will look for
01-output.log, and if that exists return
02-output.log (or next available number)? I want a command to "get the next sequentially available filename" without having to write that myself in a script.
I know I could use
date -Iseconds or similar to get unique, increasing, filenames, but is there anything that'll produce more simplier increasing filenames?
I know it's probably easy to write such a programme, but before I do it myself, I want to see if someone's already done it.
Update Someone asks "how would the script know the pattern?" I'm suggesting that much like mktemp, one would give the pattern to the programme. e.g. "Give me the next file named like output-XX.log" and the programme would look at the X's and fill in
01, look for that file, etc.