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 (Monsignor) 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.