Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get random number on command line on MacOs (like shuf)

Tags:

macos

I need add random number to filename. On Linux I use command like

filename$(shuf -i 10000000-99999999 -n 1)

But on MacOs with this command I recieve error:

sh: shuf: command not found

Here are another solution on MacOs for make it?

like image 799
Valentina Avatar asked Dec 11 '25 23:12

Valentina


1 Answers

Bash $RANDOM is a pretty good solution. Alternatively, you can use "jot", which comes pre-installed on Mac:

$ jot -r 1 10000000 99999999

if you want to generate more than one number, just change the first parameter

$ jot -r 36 10000000 99999999 // Generates 36 Unique Numbers
like image 195
bashrc Avatar answered Dec 16 '25 23:12

bashrc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!