Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2010
    Posts
    2

    Red face Unanswered: How to sort in ascending, descending and ascending in single file using shell script.

    My input Test Data
    --------------
    P1 Y A
    P2 Y C
    P4 N D
    P3 N C
    P1 X B
    P1 Y B
    P5 N A

    Condition: 1st to 3rd char and 6th character ascending order and 4 th char descending order.

    Expected Output result
    -----------------------

    P1 Y A
    P1 Y B
    P2 Y C
    P1 X B
    P5 N A
    P3 N C
    P4 N D

    Please help me it's very urgent.

    Thanks for advance.

    Thanks & Regards,
    Viany Chada

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Is this your homework? What have you done so far?

  3. #3
    Join Date
    Jun 2010
    Posts
    2

    Red face

    This is the requirement from one of our client's.

    I created sample data to understand it better.... which was updated in my query.

    Thanks,
    Vinay

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Your expected output does not match the problem description. What is it that you really need?

    Anyway, the sort utility will certainly help you.

  5. #5
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    To get your expected output using your input
    sort -k 2,2r -k 3,3 -k 1,1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •