Generate a random filename in unix shell
问题 I would like to generate a random filename in unix shell (say tcshell). The filename should consist of random 32 hex letters, e.g.: c7fdfc8f409c548a10a0a89a791417c5 (to which I will add whatever is neccesary). The point is being able to do it only in shell without resorting to a program. 回答1: Assuming you are on a linux, the following should work: cat /dev/urandom | tr -cd 'a-f0-9' | head -c 32 This is only pseudo-random if your system runs low on entropy, but is (on linux) guaranteed to