08-20-2007 07:10 PM
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..
Solved! Go to Solution.
08-20-2007 07:16 PM
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.
Owner of ISN Corporation
08-20-2007 07:31 PM
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.