Randomness in Bash and Linux: shuf and $RANDOM XD

  Рет қаралды 20,804

Luke Smith

Luke Smith

Күн бұрын

Пікірлер: 61
@bool2max
@bool2max 5 жыл бұрын
2:10 that's not arbitrary at all, that's the maximum value of a signed 16bit (2byte) integer
@henrymalinowski5125
@henrymalinowski5125 5 жыл бұрын
@@nilsirl arbitrary - "based on random choice or personal whim, rather than any reason or system"
@theredtechengineer1480
@theredtechengineer1480 4 жыл бұрын
Gabriel Sinca what about unsigned 7 bit ascii?
@martinprochazka3714
@martinprochazka3714 5 жыл бұрын
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 :)
@vmisev
@vmisev 5 жыл бұрын
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"
@geremachek
@geremachek 5 жыл бұрын
"Core yootuls"
@c.deg.7982
@c.deg.7982 5 жыл бұрын
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!
@deidara_8598
@deidara_8598 3 жыл бұрын
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_8598
@deidara_8598 3 жыл бұрын
The $((RANDOM % 10)) has a problem in that it has a slight bias towards 0-6 over 7-9. This is because the RANDOM variable generates numbers within a specific range, and unless the max of that range is perfectly divisible by the modulus, there will be a slight bias towards the remainder of the modulus divded by the max range. Another way to visualize it is to imagine RANDOM generates all numbers within its range with equal probability, now imagine taking the modulo of every number within that range, then count up the results you get, what you will discover is that the lower range of numbers will have a slightly greater advantage than the larger numbers. For a modulus of 10 is this barely noticable, but try it with 1,000 or 10,000 or 20,000, and you will start to notice the bias more clearly
@cookiedestroyer402
@cookiedestroyer402 5 жыл бұрын
>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
@rexevan6714
@rexevan6714 5 жыл бұрын
We are all hypocrites
@thebackofdoctormanhattanshead
@thebackofdoctormanhattanshead 4 жыл бұрын
He was probably talking about searching for stuff with grep IE don't do cat file | grep -i searchterm, whereas here he's using it as a pager.
@perseusarkouda
@perseusarkouda 4 жыл бұрын
while true; do v1+=lol; cat
@evelioguaperas
@evelioguaperas 5 жыл бұрын
The noose emoji we've been waiting for lmao
@ianb1923
@ianb1923 5 жыл бұрын
This comes out 6 days after I finish my python script to generate customizable random numbers. Nice
@AnastasisGrammenos
@AnastasisGrammenos 5 жыл бұрын
@@khai96x If shuf has the same quality of code as the other coreutils I doubt you can make a python copy that works faster. Since shuf is just 600 lines of C, that figures out
@mononix5224
@mononix5224 5 жыл бұрын
@@khai96x I disagree about the cryptic part, because it is intuitive to me. Now I don't know about the speed of python, but I've head a lot of people complain about how slow it is :/
@ChungusAm0ngus
@ChungusAm0ngus 5 жыл бұрын
Well, I guess fortune is useless now.
@wherestheshroomsyo
@wherestheshroomsyo 5 жыл бұрын
the modulus trick, isn't perfect by the way but it's close. Use shuf if you need perfect.
@GabrielPiveta
@GabrielPiveta 4 жыл бұрын
thanks, now i can make my god words! just like terry!!!!
@Dusta_Rhymes
@Dusta_Rhymes 5 жыл бұрын
lol xd randum bashisms UwU hehe ~~
@jan_harald
@jan_harald 5 жыл бұрын
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...
@ianpan0102
@ianpan0102 5 жыл бұрын
Hey Luke! Which font are you using in the terminal? I really like it.
@b0ba_884
@b0ba_884 5 жыл бұрын
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
@bendover4728
@bendover4728 5 жыл бұрын
This is just great! Could you please elaborate on AWK utility? Thank you a lot!
@antuacharjee9145
@antuacharjee9145 5 жыл бұрын
Make a video about awk command
@GNU_Linux_for_good
@GNU_Linux_for_good 2 жыл бұрын
08:00 Any chance Luke will share his wonderful emoji file with the rest of the community?
@jasperzanjani
@jasperzanjani 5 жыл бұрын
shuf is bloatware, real players use sort -R
@andrez76
@andrez76 5 жыл бұрын
Pardon the random question, but what keyboard do you use? Thanks.
@davidkeys4284
@davidkeys4284 2 жыл бұрын
Unicomp
@thomasschlieter5281
@thomasschlieter5281 5 жыл бұрын
Thanks, I learned something new.
@sarundayo
@sarundayo 5 жыл бұрын
Wonder if it can be used to randomly look up the weather on different parts of the world.
@xGOKOPx
@xGOKOPx 5 жыл бұрын
why not
@duyhuyhoangdo4183
@duyhuyhoangdo4183 5 жыл бұрын
what is your bash extension?
@Iglum
@Iglum 5 жыл бұрын
When are you gonna use Amazon polly to make a creepy meme voice for the videos?
@SimGunther
@SimGunther 5 жыл бұрын
Is BusyBox a meme or is it a viable coreutil replacement? Hmmmm.....
@distroverse
@distroverse 5 жыл бұрын
For small devices and containers (like Docker), Alpine Linux is a popular option and it uses Busybox. If you like being more "POSIX compliant"/correct/minimal than it is nicer option than GNU coreutils which have a lot of extensions and is so **** bloated. For example ls.c from coreutils is 5200 lines where busybox is 1000 or cp.c is 1200 and busybox 200.
@PedroSantos-ru9uw
@PedroSantos-ru9uw 5 жыл бұрын
which font are you using in this video?
@luka95kovach
@luka95kovach 5 жыл бұрын
Hey Luke, are you using polybar on your machine or i3status? It looks really nice...
@jan_harald
@jan_harald 5 жыл бұрын
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
@InNominePraxis
@InNominePraxis 5 жыл бұрын
package that allows printing color emojis in i3blocks?
@elsholz2365
@elsholz2365 5 жыл бұрын
Remove random directory from root?
@purplewarrior1830
@purplewarrior1830 3 жыл бұрын
NO
@billyblackburn864
@billyblackburn864 2 жыл бұрын
where can I get the file with all the emojis?
@Clutter.monkey
@Clutter.monkey 5 жыл бұрын
PSEUDOrandom
@MartinsTalbergs
@MartinsTalbergs 5 жыл бұрын
not true
@aedd3307
@aedd3307 4 жыл бұрын
Everything in computers is pseudorandom, its just giving some OS variables as a seed to an algorithm that will produce the same seed given the same seed
@kattengustav1
@kattengustav1 5 жыл бұрын
Upload the emoji DB!!
@muellerhans
@muellerhans 5 жыл бұрын
Why isn't your time emoji?
@YanPashkovsky
@YanPashkovsky 5 жыл бұрын
You're wrong, dev random is really random and can be used in cryptography , urandom is pseudorandom
@forcebewhithyou94
@forcebewhithyou94 5 жыл бұрын
Good stuff, men can you do, like an explanation of the man page, every time that I review one, is like language from another plane or trying to confuse the explanation, is embarrassing to me no to understand anything in there, but also this babble also is embarrassing to somebody that claim is an explanation, for a user with no expertise trying to get help.......
@hielke2332
@hielke2332 5 жыл бұрын
Take a look at tldr for shorter and simpler explenation of commands.
@Sp0nge5
@Sp0nge5 5 жыл бұрын
I thought you'd switched to Fish?
@GeorgijTovarsen
@GeorgijTovarsen 5 жыл бұрын
$((arithmetic))
@mallock8529
@mallock8529 5 жыл бұрын
this is epic colon three
@gavinvales8928
@gavinvales8928 5 жыл бұрын
New computer?
@___xyz___
@___xyz___ 4 жыл бұрын
"random"
@rajufelix3070
@rajufelix3070 5 жыл бұрын
love you man
@wiswis
@wiswis 5 жыл бұрын
not as random as /dev/random 🤦‍♂️
@lachlangreen9766
@lachlangreen9766 5 жыл бұрын
1st
The Bible on the Command Line (KJV, Greek, and Latin Vulgate)
9:06
Layin' down Pipes like a Unix Chad
10:55
Luke Smith
Рет қаралды 97 М.
PIZZA or CHICKEN // Left or Right Challenge
00:18
Hungry FAM
Рет қаралды 15 МЛН
The Singing Challenge #joker #Harriet Quinn
00:35
佐助与鸣人
Рет қаралды 34 МЛН
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 120 МЛН
Using Bash and the Terminal to understand files
14:09
Luke Smith
Рет қаралды 62 М.
Ever Noticed How "Weird" Modern TV and Film are?
12:32
Luke Smith
Рет қаралды 135 М.
Some bashrc recommendations and what I use
19:17
Luke Smith
Рет қаралды 115 М.
Julian Jaynes and the Bicameral Mind Theory
20:56
ProSocial World
Рет қаралды 53 М.
Bash commands to not look dumb at the Interview...
12:16
Luke Smith
Рет қаралды 78 М.
Unix Chad JUST WON'T STOP Piping!
12:03
Luke Smith
Рет қаралды 53 М.
Using Pacman on Arch Linux: Everything you need to know
17:44
Luke Smith
Рет қаралды 198 М.
Essential Shell/Bash Tips 2 Make U Smart on the Internet!
12:17
Luke Smith
Рет қаралды 75 М.
PIZZA or CHICKEN // Left or Right Challenge
00:18
Hungry FAM
Рет қаралды 15 МЛН