Generate a random filename in unix shell

前端 未结 14 629
说谎
说谎 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:19

    why do not use unix mktemp command:

    $ TMPFILE=`mktemp tmp.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX` &&  echo $TMPFILE
    tmp.MnxEsPDsNUjrzDIiPhnWZKmlAXAO8983
    
    0 讨论(0)
  • 2020-12-23 00:20

    uuidgen generates exactly this, except you have to remove hyphens. So I found this to be the most elegant (at least to me) way of achieving this. It should work on linux and OS X out of the box.

    uuidgen | tr -d '-'
    
    0 讨论(0)
提交回复
热议问题