Bob Proulx <b...@proulx.com> writes: > Nuno J. Silva wrote: >> In a BASH script I'm writing, I need temporary files. Unfortunately, not >> only some of the used programs don't accept stdin nor stdout, but they >> also require "extensions" on the input/output file. > > Yep. A common problem. > >> As I want to be sure nothing is overwritten, I tried calling mktemp with >> a modified template: >> >> $ mktemp tmp.XXXXXXXXXX.ext >> mktemp: too few X's in template `tmp.XXXXXXXXXX.ext' [...] >> Is this a limitation of mktemp (X's must be on the right)? > > Yes. It is a legacy limitation. As Jim mentioned a feature for this > was recently added to GNU coreutils. > > The traditional way to handle this problem was to create a temporary > directory and then create files with suffixes inside the directory. > Because the directory is uniquely named you can use a known name for > the file within the directory.
I changed it so for now it does exactly that - it's way better than the (ugly) way I was doing it (appending the suffix to the random name and aboting because it hit an existing file). -- Thanks, Nuno J. Silva gopher://sdf-eu.org/1/users/njsg