Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Sort alphabetically from file

by daxim (Curate)
on Jun 14, 2019 at 14:05 UTC ( [id://11101352]=note: print w/replies, xml ) Need Help??

in reply to Sort alphabetically from file

sort -k4 < the_input_file

Replies are listed 'Best First'.
Re^2: Sort alphabetically from file
by Lotus1 (Vicar) on Jun 14, 2019 at 15:18 UTC

    I had no idea the Unix sort could do that. Thanks for posting. I've used GNU Utilities for Win32 before but it hasn't been updated since 2003 and is getting hard to find. I found a new project with the same objective called GNU on Windows that looks promising.

    From reading the Wikipedia page for Sort it looks like the left angle bracket redirect, '<', isn't needed to read the input file. Also, I noticed that Windows Server 2012 includes a command called sort that doesn't have the -k option. That's a pity since not only does it have less functionality than the Unix version but also it complicates setting up a path to the GNU version with the same name.

      If you're stuck in Wintendo land there's also Cygwin which has the GNU stuff and lots of other open source stuff.

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

        I shifted from cygwin to MSYS2 some time ago, although I am increasingly using the Windows Subsystem for Linux on Win10 boxes. That said, I use them in isolation so none of them are in my windows path.

        The PerlPowerTools might also be useful, although I have never tried them myself.

        I stopped installing cygwin since I discovered git's bash terminal is supporting most of bash

         ls -l | grep NT | sort -k5

        works fine for me! :)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        Yes, I've used Cygwin for years on my personal laptops but it isn't an option for me at work on corporate Windows servers. Up until ten years ago one of our software vendors was including the GNU Utilities on certain machines but that is no longer the case. I end up reinventing the GNU wheels. Would those be GNU-er wheels?

Re^2: Sort alphabetically from file
by bliako (Abbot) on Jun 15, 2019 at 00:30 UTC

    Just for the laugh of it:

    Windows (the trademarked (C) "operating system" the swiss-...-cheese of operating systems) offers its own cmd line sort function aptly named sort. (I have learned this fact from: Re: Sorting a text file). From some initial (and final) enquiries it looks like it sorts on unit-character columns! So, it is practically a useless executable occupying space just like so many of its siblings. The ever so helpful people (don't ever ask there a question how to suicide lest you want an overflow) of stack overflow suggest using a spreadsheet to sort a file if you find yourself in a Windows system! Or install GNU utils in order to benefit from the Unix sort.

    Thanking Unix, thanking GNU, thanking Perl for my everyday sanity.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11101352]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-06-24 23:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.