![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sorting based on Multiple columns | dharmesht | Shell Programming and Scripting | 15 | 05-13-2009 10:44 AM |
| Removing lines that are (same in content) based on columns | adsforall | UNIX for Dummies Questions & Answers | 7 | 11-09-2007 12:13 PM |
| Sorting based on columns | MobileUser | Shell Programming and Scripting | 7 | 04-11-2007 02:03 PM |
| sorting file content on columns | marshmallow | UNIX for Dummies Questions & Answers | 2 | 01-04-2007 12:10 PM |
| sorting a file with multiple columns | outtacontrol | UNIX for Dummies Questions & Answers | 3 | 07-26-2006 01:51 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
sorting data based on multi columns
Hi all
I have data in following format: CSCH74,2007,1,09103,15 CSCH74,2007,10,09103,0 CSCH74,2007,11,09103,0 CSCH74,2007,12,09103,0 CSCH74,2007,2,09103,15 CSCH74,2007,3,09103,194 CSCH74,2007,4,09103,115 CSCH74,2007,5,09103,66 CSCH74,2007,6,09103,0 CSCH74,2007,7,09103,0 CSCH74,2007,8,09103,0 CSCH74,2007,9,09103,0 CSCS74,2007,1,09103,142 CSCS74,2007,10,09103,0 CSCS74,2007,11,09103,0 CSCS74,2007,12,09103,0 CSCS74,2007,2,09103,1224 CSCS74,2007,3,09103,1332 CSCS74,2007,4,09103,1169 CSCS74,2007,5,09103,195 CSCS74,2007,6,09103,0 CSCS74,2007,7,09103,0 CSCS74,2007,8,09103,0 CSCS74,2007,9,09103,0 I want to sort it so that output is ( basically sort on column1 and 3) CSCH74,2007,1,09103,15 CSCH74,2007,2,09103,15 CSCH74,2007,3,09103,194 CSCH74,2007,4,09103,115 CSCH74,2007,5,09103,66 CSCH74,2007,6,09103,0 CSCH74,2007,7,09103,0 CSCH74,2007,8,09103,0 CSCH74,2007,9,09103,0 CSCH74,2007,10,09103,0 CSCH74,2007,11,09103,0 CSCH74,2007,12,09103,0 CSCS74,2007,1,09103,142 CSCS74,2007,2,09103,1224 CSCS74,2007,3,09103,1332 CSCS74,2007,4,09103,1169 CSCS74,2007,5,09103,195 CSCS74,2007,6,09103,0 CSCS74,2007,7,09103,0 CSCS74,2007,8,09103,0 CSCS74,2007,9,09103,0 CSCS74,2007,10,09103,0 CSCS74,2007,11,09103,0 CSCS74,2007,12,09103,0 I have tried : sort -t, +2 -3 +0 -1 file sort -t, -k3,3 n -k1,1 file sort -t"," -k3,3 n -k1,1 file result is not what I wanted CSCH74,2007,1,09103,15 CSCS74,2007,1,09103,142 CSCX74,2007,1,09103,28 CSYH74,2007,1,09103,57 CSYS74,2007,1,09103,165 CSYX74,2007,1,09103,11 D13H41,2007,1,08475,5 D13H42,2007,1,08475,43 D13H62,2007,1,08475,1 D13H81,2007,1,08475,12 D13L41,2007,1,08475,0 sort -t, -k1,1 -k3,3 n file sort -t"," -k1,1 -k3,3 n file sort -t"," -k 1,1 -k 3,3 n file for all the above command the output is same as input file with statement cannot open 'n' and in last case cannot open -k 3,3 and n. sort -t, -k1,1 -k3,3 -n file (comes up with usage of sort command) nothing seems to work. any help from Unix Gurus is appreciated. Thanks Sumeet |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|