Contents |
uniqname is an extremely simple script to generate a timestamp that can be used to define labels, filenames, variables, etc., which are unique if not invoked more than once per second.
A typical use is as a label in $\mathrm{\TeX}$ documents, or as a filename for temporary documents or quick notes (today, for instance, I sent a file called "WedAug29164757CEST2012.pdf" to co-workers).
By running it just now, I get:
uniqname WedAug29194222CEST2012
The WedAug29194222CEST2012 string is a unique timestamp (within 1s of accuracy).
This is working well and is useful only with English dates. Compare with jeu.19déc.2024232410CET using the
laussy@azag:~$ echo $LC_TIME fr_FR.UTF-8
so-called locale. This can be enforced from the script itself (adding the line LC_TIME=POSIX in the script, making it v1°0) or by setting it globally (e.g., adding the same LC_TIME=POSIX in ~/.bashrc).
#!/bin/bash #Unique Name generator based on date #F.P. Laussy #Fri May 6 10:27:47 UTC 2005 v0°1 #Thu Dec 19 23:49:12 CET 2024 v1°0 LC_TIME=POSIX date | tr -d ": " | tr -d "\n"