Shell scripts, aliases, and other programs can need temporary files to hold data used later. If the program will be run more than once, or if the temp file needs to stay around after the program is done, you need some way to make a unique filename.
One way is with the shell's , available in the You might name a file /tmp/MYPROG$$; the shell will turn that into something like /tmp/MYPROG1234 or /tmp/MYPROG28471. If your program needs more than one temporary file, add an extra unique character to the names:
Remember the 14-character filename limit on some older UNIXes. $$ usually makes two to five characters.
dateThu May 30 07:21:13 EDT 1991 %
+ parameter and
to get a temp file named for the current date and/or time.
For instance, on May 31 the command below would store foo.0531 in the Bourne shell variable temp.
On December 7, it would store foo.1207:
Article 21.3 shows another system for temporary files.
|16.15 Script with a :-) for UNIX Converts: dir, ..., ...||16.17 Getting Directory Name from a File's Pathname|