bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: new coreutil? shuffle - randomize file contents


From: Lemley James - jlemle
Subject: RE: new coreutil? shuffle - randomize file contents
Date: Tue, 24 May 2005 10:35:36 -0500

I'm just a lurker so my opinion doesn't count.  for much.

Certainly I don't expect everyone to be a programmer in order to be able
to shuffle their playlist, but perhaps an example needs to be added to
the sort man-page stating how easy is to accomplish with tools that are
likely already installed on your system (specifically, "awk" to add a
pseudorandom key to a line and "cut" to remove it): 

find /music -name '*ogg' -type f | 
awk 'BEGIN{srand()}{printf "%06d%s\n", rand()*1000000, $0}' | 
sort | 
cut -b 7- > /music/randomized_oggfiles.m3u

Remove srand() if you prefer more deterministic behavior.   Standard
disclaimers about using pseudorandom numbers for anything important
apply.

As to adding a random function to sort that would keep like-keys
together, perhaps that can be achieved by abusing the locales and
collate function that does unexpected things for many users anyway?  I'm
only half serious when I say that, but LANG=(something other than C) has
caused so many users so much grief already that LANG=random couldn't be
any worse. 

Apologies for the noise on the list, but I hope you got a chuckle from
LANG=random anyway.  I'll go back to lurking now. 


James Youngman wrote:

>I don't agree. You just end up duplicating
>99% of the sort logic. Logically the only difference from sort
>is the low level ordering algorithm. so I vote for and extra arg to 
>sort: --sort="random". Another arg to the --sort option could be,
>"version" which would sort files with version numbers in their name
>appropriately.



**********************************************************************
The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged.
If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, 
distribution, or copying of this communication is strictly
prohibited.
If you have received this communication in error,
please re-send this communication to the sender and
delete the original message or any copy of it from your
computer system. Thank You.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]