Randomness in Bash and Linux: shuf and $RANDOM XD

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

2:10 that's not arbitrary at all, that's the maximum value of a signed 16bit (2byte) integer

boolmax
Автор

You are breaking the randomness by using the modulo "hack". For example if you have generator giving you numbers 0...5 and you need 0..4 so you modulo it by 5. It maps numbers this way 0-0, 1-1, 2-2, 3-3, 4-4, 5-0, as you can see there is double chance that 0 is generated relative to other numbers (in this case). So be careful with this method :)

martinprochazka
Автор

Thanks for the tip on modulo for $RANDOM - I like that very much :)

BTW, you are correct about shuf in FreeBSD - it's in ports (sysutils/shuf);
and gshuf is installed with GNU coreutils (sysutils/coreutils).

jot(1) is tool that's in base, but options are different, e.g. "-r" in jot(1) "generates random data instead of the default sequential data"

vmisev
Автор

>Luke in live stream 3 days ago
>"don't ever use cat its for brainlets use grep + inputs etc.
>luke today
>cat cat cat cat cat cat
my brain hurts

cookiedestroyer
Автор

Cryptographically secure randomness isn't just about entropy, it also has to do with the source of randomness. A Mersenne twister has high entropy, but the randomness is seeded and deterministic, so the security of keys generated with that type of randomness will hinge purely on the seed chosen, which is undesirable. /dev/urandom takes its randomness from several sources which collectively makes it extremely hard to predict, which makes it optimal for generating secure cryptographic keys.

deidara_
Автор

This comes out 6 days after I finish my python script to generate customizable random numbers.


Nice

ianb
Автор

Now start saying random things in the tutorial, and maybe random people with a dark complexion, from random alphabet soup institutions that emit random rays of light in the night will come to visit your location on a random day!

c.deg.
Автор

the modulus trick, isn't perfect by the way but it's close. Use shuf if you need perfect.

wherestheshroomsyo
Автор

The noose emoji we've been waiting for lmao

evelioguaperas
Автор

thanks, now i can make my god words! just like terry!!!!

GabrielPiveta
Автор

function randomnumber { shuf -i ${1:-1}-${2:-10} -r -n 20|shuf -n1; }
very simple random number function with shuf, with optional range specification, probably better than $RANDOM anyway ;P
makes repeating pool of 20, then chooses one of them, defaults to range 1-10
if you want to bother, you can make it so that one argument = second range argument, but if both then first = first, and such... kinda pointless tho...

jan_harald
Автор

Well, I guess fortune is useless now.

ChungusAmngus
Автор

Hey Luke! Which font are you using in the terminal? I really like it.

ianpan
Автор

shuf is bloatware, real players use sort -R

jasperzanjani
Автор

This is just great! Could you please elaborate on AWK utility? Thank you a lot!

bendover
Автор

I really like your content and because of your tutorials and LARBS i have i3 with arch know but i was thinking to move to gentoo, what is your opinion and which one is better

bba_
Автор

08:00 Any chance Luke will share his wonderful emoji file with the rest of the community?

GNU_Linux_for_good
Автор

Pardon the random question, but what keyboard do you use? Thanks.

andrez
Автор

why'd you put XD in title, lol
also as mentioned before, why $RANDOM if you can `strings /dev/urandom|grep "[0-9]"|head -c100` or such ;P

jan_harald
Автор

Wonder if it can be used to randomly look up the weather on different parts of the world.

sarundayo