• Is there a standard Unix tool to create permutations?

    From Janis Papanagnou@21:1/5 to All on Tue Mar 22 17:48:57 2022
    Is there a standard Unix tool to create permutations?

    I am using 'shuf' to create permutations of data, and in
    GNU context I can also use 'sort -R' for that, it seems.
    But inspecting the utilities section of the POSIX specs I
    haven't found any tool for that purpose. - Is there any?

    Note: I can of course use awk and program my own function,
    but I was looking for a - similar to 'shuf' - ready to use
    standard tool.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ed Morton@21:1/5 to Janis Papanagnou on Tue Mar 22 12:37:17 2022
    On 3/22/2022 11:48 AM, Janis Papanagnou wrote:
    Is there a standard Unix tool to create permutations?

    I am using 'shuf' to create permutations of data, and in
    GNU context I can also use 'sort -R' for that, it seems.
    But inspecting the utilities section of the POSIX specs I
    haven't found any tool for that purpose. - Is there any?

    Note: I can of course use awk and program my own function,
    but I was looking for a - similar to 'shuf' - ready to use
    standard tool.

    Janis

    I've seen so many Q&A online about permutations over the years with
    no-one ever suggesting a Unix tool that does it that I think I can
    safely say "no".

    Ed.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to Janis Papanagnou on Tue Mar 22 18:21:29 2022
    On Tue, 22 Mar 2022 17:48:57 +0100, Janis Papanagnou wrote:

    Is there a standard Unix tool to create permutations?

    I am using 'shuf' to create permutations of data, and in
    GNU context I can also use 'sort -R' for that, it seems.
    But inspecting the utilities section of the POSIX specs I
    haven't found any tool for that purpose. - Is there any?

    Note: I can of course use awk and program my own function,
    but I was looking for a - similar to 'shuf' - ready to use
    standard tool.

    Don't know if this fits your use-case, but the ptx(1) command
    permutes it's inputs. ptx(1) builds a permuted index of a
    file's contents, and is used to create the "permuted index"
    index page in unix (paper) manuals.

    Perhaps the permutations that ptx(1) builds will suffice for
    your use-case

    HTH
    --
    Lew Pitcher
    "In Skills, We Trust"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lew Pitcher on Wed Mar 23 15:46:20 2022
    On 22.03.2022 19:21, Lew Pitcher wrote:
    On Tue, 22 Mar 2022 17:48:57 +0100, Janis Papanagnou wrote:

    Is there a standard Unix tool to create permutations?

    I am using 'shuf' to create permutations of data, and in
    GNU context I can also use 'sort -R' for that, it seems.
    But inspecting the utilities section of the POSIX specs I
    haven't found any tool for that purpose. - Is there any?

    Note: I can of course use awk and program my own function,
    but I was looking for a - similar to 'shuf' - ready to use
    standard tool.

    Don't know if this fits your use-case, but the ptx(1) command
    permutes it's inputs. ptx(1) builds a permuted index of a
    file's contents, and is used to create the "permuted index"
    index page in unix (paper) manuals.

    Perhaps the permutations that ptx(1) builds will suffice for
    your use-case

    On first glance it seems to be as usable as shuf is. Though I
    cannot find this tool as standard tool of the POSIX utilities
    as well. - As indicated, I can already solve the task. I was
    just looking whether there's a standard tool I could use just
    in case that I had to work in a standard environment. Thanks.

    Janis


    HTH


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)