Menu

shuf in gnuwin32?

Help
LennyCZ
2011-03-04
2012-07-26
  • LennyCZ

    LennyCZ - 2011-03-04

    Hi guys,

    I could not find shuf in GnuWin32, so I assume it hasn't been not ported to
    win (yet?)

    Do you have any tip to achieve the same functionality?

    What I actually need is to list all files in a folder (find c:\windows) and
    provide each item to an executable in random order. I was planning something
    like:

    find c:\windows | shuf > list.txt

    for /f %%G in (list.txt) do (

    dosomething with %%G

    )

     
  • Allan

    Allan - 2011-03-14

    Hi guys,

    I could not find shuf in GnuWin32, so I assume it hasn't been not ported to
    win (yet?)

    Do you have any tip to achieve the same functionality?

    What I actually need is to list all files in a folder (find c:\windows) and
    provide each item to an executable in random order. I was planning something
    like:

    find c:\windows | shuf > list.txt

    for /f %%G in (list.txt) do (

    dosomething with %%G

    )

    You may need to write a simple program yourself using a pseudo-random number
    generator or even the `noise.sys' hardware prng driver. The source code of
    shuf itself may give you some hints on how to do this, otherwise look at
    standard programming references.

     
  • Jay Satiro

    Jay Satiro - 2011-03-14

    Later versions of sort have a random sort option:

    -R, --random-sort sort by random hash of keys
    --random-source=FILE get random bytes from FILE

    I included a test build of sort-7.6 with the automated gnuwin32 download tool.
    You might want to try that.

    C:\gnuwin32\bin>find c:\windows | sort-7.6 --random-sort > c:\temp\random-
    sorting.txt

    https://sourceforge.net/projects/getgnuwin32/

    Click the download button

    Run GetGnuWin32-0.6.3.exe to extract the files

    You do not need to run download.bat if all you want is sort-7.6. It is located
    in the GetGnuWin32\bin directory. Copy the exe to wherever you like.

    sort (GNU coreutils) 7.6
    Copyright (C) 2009 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <[url]http://gnu.org/licenses/gpl.html[/url]>.
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    
    Written by Mike Haertel and Paul Eggert.
    
     
  • LennyCZ

    LennyCZ - 2011-03-14

    Thank you, guys!

    Finally I decided to solve the problem by moving everything into a Perl
    script. Without using any modules (not even warnings--of course, I'm not
    living without it, I just remove it each time after deployment), Perl is still
    so powerful, but as portable as copying 1 exe and 2 DLLs (for each arch, if
    necessary).

    However, thanks a lot for tips!

    raysatiro: thanks, it works like a charm! :)

     
MongoDB Logo MongoDB