How to sort using awk ?

Posted on 2009-02-24
Medium Priority
Last Modified: 2012-05-06
I need to sort the following row using the awk. How can I sort using the third column in descending/ascending order ?

host6  dev406mum.dd.mum.test.com          22               11               11               no
host7  dev258mum.dd.mum.test.com          36               17               19               no
host7  dev273mum.dd.mum.test.com          41               23               18               no
host7  dev296mum.dd.mum.test.com          41               15               26               no
host7  dev339mum.dd.mum.test.com          61               20               41               no
host4  dev271mum.dd.mum.test.com          27               21               6                no
host4  dev299mum.dd.mum.test.com          12               11               1                no
Question by:beer9
  • 2

Accepted Solution

leh327 earned 500 total points
ID: 23722380
if you have access to "sort", the syntax is
sort -k 3 -n -r

-k 3 - for third field
-n - for numeric sort
-r - for descending

Author Comment

ID: 23730890
Thanks, it works for me! :)

Author Closing Comment

ID: 31550477
Thanks! :)

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

850 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