Generate a random filename in unix shell

前端 未结 14 715
说谎
说谎 2020-12-22 23:39

I would like to generate a random filename in unix shell (say tcshell). The filename should consist of random 32 hex letters, e.g.:

c7fdfc8f409c548a10a0a89a7         


        
14条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-23 00:14

    This answer is very similar to fmarks, so I cannot really take credit for it, but I found the cat and tr command combinations quite slow, and I found this version quite a bit faster. You need hexdump.

    hexdump -e '/1 "%02x"' -n32 < /dev/urandom
    

提交回复
热议问题