-
-
Save georgepence/e8ef86463cfa486d624723e074b04755 to your computer and use it in GitHub Desktop.
Generate random numbers in Mac OS X using /dev/random or /dev/urandom using a shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Make sure to `chmod u+x random_number` in order to make this file go | |
| #!/bin/bash | |
| # Generate random strings on Mac OS X | |
| # the `tr` uses a regex to decide which characters you want to include | |
| # This is very slow as a bash script, random seems faster than urandom | |
| # though I have been told that one just symblinks the other so that would | |
| # then not be possible to be faster. | |
| # Here is some sample output from the below: | |
| # 4o)lATvDFr17gH(*fu2+ | |
| # EXF)83gtE*fcIsZYlaDu | |
| # qGA7Pb=Q@w#6F!2mJ8=j | |
| # V6mPClwZ1qZ(X8hxHI@t | |
| # +N1wwS8h#0%jbB1e@z*x | |
| # #vvJMscG*oXs#ex7ivnc | |
| # p(xFYVK)91kJjfXr2!sB | |
| # IW5kB8Q4uvFQm_J%4bbu | |
| # m6^9y=RWroBNfpNzyBXI | |
| # 47=&3Jc5zzAg)X8(OF%s | |
| # )C_I%!6zJ!*appXlz=VE | |
| # Lv@^3rRYQECP)RkxlUs | |
| i="0" | |
| while [[ $i -lt 40 ]]; | |
| do | |
| LC_CTYPE=C tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= < /dev/random | head -c 20 | xargs | |
| i=$[$i+1] | |
| done; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment