# [Shell] random number



## ohyes (May 21, 2014)

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 
	
	



```
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 (May 21, 2014)

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 (May 21, 2014)

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 -


----------



## wblock@ (May 21, 2014)

`jot -r 5 1 50 | sort -n`


----------



## DutchDaemon (May 21, 2014)

Yeah, that's what jot is for ..


----------

