Sample Header Ad - 728x90

Idiomatic way of generating a unique filename?

12 votes
7 answers
3378 views
In a script I'm writing, I want to create something temporary on my filesystem, but - it's not in /tmp but elsewhere, and may not be a file nor a directory (e.g. maybe it's a named pipe or a symbolic link). The point is - I'll have do the creation myself. Now, I want to use a unique filename for my temporary, so that future invocations of the utility plus any other running code won't try to use the same name. If I were just creating a temporary file or directory in /tmp, I could use mktemp. But - what do I do when I only want to generate the name?
Asked by einpoklum (10753 rep)
Apr 27, 2025, 09:08 AM
Last activity: Apr 30, 2025, 08:14 AM