Generate a random filename in unix shell

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

    Grab 16 bytes from /dev/random, convert them to hex, take the first line, remove the address, remove the spaces.

    head /dev/random -c16 | od -tx1 -w16 | head -n1 | cut -d' ' -f2- | tr -d ' '
    

    Assuming that "without resorting to a program" means "using only programs that are readily available", of course.

提交回复
热议问题