Simple sort command

Posted on 2004-11-17
Last Modified: 2012-05-05
Below is a command
    sort -t: +2n myfile
I know it will sort the 3rd field numerically

Now I have this
    sort -t: +2n -3 myfile
I see this in my textbook but then what is the use? I don't understand :(
Question by:sonic2000
    1 Comment
    LVL 23

    Accepted Solution

    This syntax is used to specify a range of positions on the line.
    Specifically, it sorts numerically on the character in position 2.

    From the sort man page:

    +POS1 [-POS2]
                  Specify  a  field within each line to use as a sorting key.  The
                  field consists of the portion of the line starting at  POS1  and
                  up  to  (but  not  including) POS2 (or to the end of the line if
                  POS2 is not given).  The fields and character positions are num-
                  bered starting with 0.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. Please see for the updated article. It is avail…
    I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now