How does this handle files that are gigs in size? It looks to me like you load the entire file into memory and pass it along, shuffled.
How to Shuffle and Sample on the Command-Line
11–20 of 21 posts
Re: How to Shuffle and Sample on the Command-Line
#12Interesting. I did the same investigation myself a few years back, but was frustrated by the lack of the -r flag for shuf(1). It seems that's been added at some point recently (though many of my systems do not have it--GNU coreutils percolates slowly through older Debian/Ubuntu versions. :)) Good to know things are still getting better in coreutils!
shuf -r -z -n 100 -e 1 2 3 4 5 6;echo -e "\n"
And rolls of a non-transitive (Grime) die shuf -r -z -n 100 -e 3 3 3 3 3 6;echo -e "\n"
Which is timely. I sometimes forget how flexible the terminal prompt is...Re: How to Shuffle and Sample on the Command-Line
#13man shuf
Re: How to Shuffle and Sample on the Command-Line
#14Nice! I've been using sort -r | head -n100 but obviously this requires the entire file to be shuffled before printing the first 100 lines.
Re: How to Shuffle and Sample on the Command-Line
#15Interesting. I did the same investigation myself a few years back, but was frustrated by the lack of the -r flag for shuf(1). It seems that's been added at some point recently (though many of my systems do not have it--GNU coreutils percolates slowly through older Debian/Ubuntu versions. :)) Good to know things are still getting better in coreutils!
Oh, nice, on Fedora 23 beta, I can simulate die rolls shuf -r -z -n 100 -e 1 2 3 4 5 6;echo -e "\n" And rolls of a non-transitive (Grime) die shuf -r -z -n 100 -e 3 3 3 3 3 6;echo -e "\n" Which is timely. I sometimes forget how flexible the terminal prompt is...
Re: How to Shuffle and Sample on the Command-Line
#16 > 1..100 | Get-Random
72
> 1..100 | Get-Random -count 3
16
96
56
but doesn't have something like -r to resample. Or a nice way to simply shuffle the whole collection (workaround is to just pass -count as large or larger than the collection).Re: How to Shuffle and Sample on the Command-Line
#17Earlier quoted context omitted.
Oh, nice, on Fedora 23 beta, I can simulate die rolls shuf -r -z -n 100 -e 1 2 3 4 5 6;echo -e "\n" And rolls of a non-transitive (Grime) die shuf -r -z -n 100 -e 3 3 3 3 3 6;echo -e "\n" Which is timely. I sometimes forget how flexible the terminal prompt is...
It's pseudo-random though, right?
Re: How to Shuffle and Sample on the Command-Line
#18Re: How to Shuffle and Sample on the Command-Line
#19Re: How to Shuffle and Sample on the Command-Line
#20man shuf
http://linux.die.net/man/1/shuf
since if it's not on the internet, how will anyone ever find it?