vendredi 27 novembre 2015

Make directory from generated hash output

This bash command generates a short hash that I'd like to use to name a directory created with mkdir:

cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1

Which (I think):

  1. Creates a random-ish number
  2. Limits the character set with tr (translation)
  3. Folds/wraps each line of output at 32 characters
  4. Limits output to one line starting at the start with head

I can simply copy the output of this command and paste it into a mkdir command, but how would it be done in a single command?

I tried adding | mkdir and | mkdir -p to then end, thinking I could pipe the output to mkdir.




Aucun commentaire:

Enregistrer un commentaire