Solved

in Bash's Sort, how do I sort by a second or third field ?

Posted on 2008-10-21
2
921 Views
Last Modified: 2013-12-27
On solaris I have data:  

N00412L3.daysold 140 37
N00160L3.daysold 18 38
N00158L3.daysold 11 39

the 14 days old of the tape and I want to sort to find tapes over 90.

I think sort with a -t or a -k may do it.  I think this is not written about much on the web :)


0
Comment
Question by:itguy411
2 Comments
 
LVL 20

Accepted Solution

by:
edster9999 earned 300 total points
ID: 22767668
sort -k 2
would sort the list based on the second field
this doesn't really work as it will be in this order :

N00158L3.daysold 11 39
N00412L3.daysold 140 37
N00160L3.daysold 18 38

as it is done by alphabet order so it is looking at 11, 14, 18

sort -k 2 -n
gets it sorted by numbers :

N00158L3.daysold 11 39
N00160L3.daysold 18 38
N00412L3.daysold 140 37

and finally
sort -k 2 -n -r
the -r gets it in reverse order

N00412L3.daysold 140 37
N00160L3.daysold 18 38
N00158L3.daysold 11 39

so now you can go down the list until you hit 90.
0
 

Author Closing Comment

by:itguy411
ID: 31508299
This really helps me

You rocke

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

23 Experts available now in Live!

Get 1:1 Help Now