• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

[Shell] random number

ohyes

Member

Thanks: 1
Messages: 56

#1
Hello §e,

I'm trying to get a random number with a shell command (bash, but another shell will be ok). Just for getting the next Euromillion's Jackpot (a random number game in Europe). :)

With Linux, the shuf command does that. I do not have try it (have no Linux), but this link http://www.tux-planet.fr/gagner-au-loto-grace-a-linux/ give the command (for another game).

Something like (adapted for the Euromillion):
echo $(shuf -i 1-50 | head -n5 | sort -n) - $(shuf -i 1-11 | head -n2 | sort -n)

But the shuf command is
Code:
bash: shuf: command not found
Well. Does Somebody know another command?
(the winner will get 1% of my gain - if over a million :beergrin)
 

obsigna

Aspiring Daemon

Thanks: 334
Messages: 646

#2
shuf is part of the GNU coreutils port sysutils/coreutils.

Either, install said port:
cd /usr/ports/sysutils/coreutils; make install clean
echo $(gshuf -i 1-50 | head -n5 | sort -n) - $(gshuf -i 1-11 | head -n2 | sort -n)

Or, if you don't want to buy the whole pork only to get a sausage for one time immediate consumption:
cd /usr/ports/sysutils/coreutils; make
cd work/stage/usr/local/bin
echo $(./gshuf -i 1-50 | head -n5 | sort -n) - $(./gshuf -i 1-11 | head -n2 | sort -n)
cd /usr/ports/sysutils/coreutils; make clean
 

ohyes

Member

Thanks: 1
Messages: 56

#3
Great. Very thanks you.
A promise is a promise. Don't trash your FreeBSD account for the next 5 years, @obsigna.
If I win you win.

- closed -
 
Last edited by a moderator: