BladeSystem Forums have moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Showing results for 
Search instead for 
Do you mean 

sort help

SOLVED
Go to Solution
Highlighted
Advisor

sort help

Hi experts,

I have a comma separated file.
The fourth field in the file is date of the form: DD-MON-YYYY format.
I wanted the file sorted according to the fourth field.
DD : 01-31
sort -knr4 wont work.
sort +3 -4 also dint work..

Please help.
3 REPLIES
Exalted Contributor

Re: sort help

Shalom,

From my new memory leak monitor.

CL="ps -o pid,args,sz,vsz | sort -nr -k 3,4| head -$NUM"


This sorts by field three then field 4.

All you need to do is get the field separator right.

I would suggest a combination of awk and sort.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Acclaimed Contributor

Re: sort help

>I wanted the file sorted according to the fourth field.

You need to break up the fourth field into 3 fields with "." syntax.

>SEP: I would suggest a combination of awk and sort.

No need, sort(1) has enough horsepower:
sort -t, -k4.8n,4.11n -k4.4M,4.6M -k4.1n,4.2n file

Use the "." notation to get bytes within field 4. Use "M" to sort by months.
Advisor

Re: sort help

Thanks Dennis..
It worked exactly as I wanted...