Created
November 6, 2025 01:11
-
-
Save s1037989/233aac66589be102bb3351ce7a4987f0 to your computer and use it in GitHub Desktop.
bash random number generator
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
| # Source - https://stackoverflow.com/questions/1194882/how-to-generate-random-number-in-bash | |
| # Posted by s1037989 | |
| # Retrieved 2025-11-05, License - CC BY-SA 4.0 | |
| rand() { | |
| perl -E '$ARGV[0]||=""; $ARGV[0]=int($ARGV[0])||length($ARGV[0]); say join "", int(rand(9)+1)*($ARGV[0]?1:0), map { int(rand(10)) } (0..($ARGV[0]||0)-2)' $1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment