Say I have a folder with a few thousand documents/images. What would be the simplest method to randomly select and retrieve 500 of them?
I was thinking of feeding them all into an elasticsearch instance and randomly getting them that way, but surely there's an easier way?
Say I have a folder with a few thousand documents/images...
Other urls found in this thread:
sanctum.geek.nz
twitter.com
That's like 5 lines in bash... Are you retarded?
yes, but thanks for pointing me in the right direction
find -type f -maxdepth 1 | shuf -n 500
thx.now how do i stop being a fucking retard and learn this shit? just man everything?
Dude. That's like ONE line in bash.
Just get gud
BBRRRRRRAAAAAAAAAPPPPPFFFT
well you got an A in unix class
fugg :DDD
shuf is the key thing of interest, since it'll shuffle whatever sort of list is piped into it. From there, you just have to figure out a way to get the list of files.
Obviously, works, but it's not ideal, since find is a truly awful program -- way too complex, way too finicky. grep is simpler and better, and -- in a perfectly Unix-y way -- it can be paired with ls to get the result.
ls -F | grep -v /$ | shuf -n 500
ls -F will append / to directories; this is useful since (without colors or anything fancy) directories are normally indistinguishable from regular files. The entire list of files/directories gets piped into grep, which then removes (that is, inverse searches, via -v) any line that ends with /. Note that, because of the way most Linux/Unix/whatever file systems work, a regular file can't/shouldn't contain / in its name, so we could remove the $ from the grep command it'd probably work the same.
shuf, of course, does what you'd expect: shuffles the input line-wise and then takes the first 500 lines.
parsing ls is gonna bite you in the end. find is probly way slower but it also has a -type f which is more reliable than whatever you're doing to pick non-slashhed filenames.
I owe you guys a few beers
also something for yall 'ls |' people to think about, find has a "secure" -delete command so you dont have to send a file named filename_$(rm -rf /).txt to | rm like a fucking retard.
This is to get random pics from a fap folder, isn't it?
i wish i were memeing, but no. i guess i'll explain since i'm a fucking retard and im sure there are several competent anons here. the purpose of this is to train object detection apps.my fap folder is pretty well categorized as is
So do you know where it's from or who that is?
ls -1 | shuf -n 500
don't know where they're from, but interns have annotated what im looking for. also, an image in one directory is related to an .xml annotation in another.
but what has been posted so far has been a tremendous help already!
Train one to sort new shit to your fap folder for you!
im working on something like this too kek
Never parse ls.
I remember this image from so long ago, still can't find the sauce.
>mfw sniffs the BRAAAPP
If I had a crazy amount of money I would literally suffocate in female ass.
Find is not even Bash.
>5 lines
pleb
regex fool
go to memrise and learn