How would you: find exec (sorted/random pipe)?

Need help with C, C++, perl, python, etc?

How would you: find exec (sorted/random pipe)?

Postby bester69 » 2020-05-28 22:40

Hi,
How would you do a : find -exec RANDOM? :?:

I was trying something like this:
>> find . -type f |sort -R| find -type f -exec command "{}" \;

And making some tries, I came to this kind of solution.:
find . -type f | sort -R | xargs -I{} find {} -exec command {} \;

It seems to work.. :shock: , do you think its ok?
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1747
Joined: 2015-04-02 13:15

Re: How would you: find exec (sorted/random pipe)?

Postby bester69 » 2020-05-28 23:10

This two seems to work... good!!, I now know how to make this kind of operation.

find . -type f | sort -R | xargs -I{} find {} -exec command {} \;

find . -type f -print 0| sort -zR | xargs -0 -I{} find {} -exec command {} \;


:o
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1747
Joined: 2015-04-02 13:15

Re: How would you: find exec (sorted/random pipe)?

Postby Head_on_a_Stick » 2020-05-29 15:45

I know you think I'm just being a **** but it really would be best if you explain why you want a randomised order, there might be a better way of acheiving your goal.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12650
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: How would you: find exec (sorted/random pipe)?

Postby bester69 » 2020-05-29 17:47

Head_on_a_Stick wrote:I know you think I'm just being a **** but it really would be best if you explain why you want a randomised order, there might be a better way of acheiving your goal.

I wonder, why would you ask me such a question? :shock:

I have hunderths of mp3u files I want to concat them in a randomly way everytime I launch the player, so It can play that huge playlist with a RANDOM new song everytime, and those concat files need a header #EXTINF, for each song to be able to be played, so you just cant concat all files, and then, later sort it randomly, that would also order randomly headers titles #EXTINF.... so, this is the case here, but i do this kind of things very usually...

find . -name "*.m3u" | sort -R | find -exec cat {} > biglist.m3u \;
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1747
Joined: 2015-04-02 13:15

Re: How would you: find exec (sorted/random pipe)?

Postby Head_on_a_Stick » 2020-05-30 09:13

Try shuf(1) instead of sort(1), it's *much* faster and it does actually randomise the list properly.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12650
Joined: 2014-06-01 17:46
Location: /dev/chair


Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable