Skip to content

Instantly share code, notes, and snippets.

@brohee
Last active February 1, 2023 15:01
Show Gist options
  • Save brohee/d411ddb840bb1268c9f31626ef73ff08 to your computer and use it in GitHub Desktop.
Save brohee/d411ddb840bb1268c9f31626ef73ff08 to your computer and use it in GitHub Desktop.
Generate long random numerical string in shell for e.g. PIN generation
#!/bin/sh
dd if=/dev/random bs=15 count=1 2>/dev/null | od -D | cut -c 15- | tr -d ' ' | head -1
# alias pin4="dd if=/dev/random bs=15 count=1 2>/dev/null | od -D | cut -c 15- | tr -d ' ' | head -1 |cut -c 1-4"
# alias pin6="dd if=/dev/random bs=15 count=1 2>/dev/null | od -D | cut -c 15- | tr -d ' ' | head -1 |cut -c 1-6"
# alias pin8="dd if=/dev/random bs=15 count=1 2>/dev/null | od -D | cut -c 15- | tr -d ' ' | head -1 |cut -c 1-8"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment