![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to sort a field in a file having date values | risshanth | Shell Programming and Scripting | 4 | 06-04-2008 02:03 AM |
| sort columns by field | kamel.seg | Shell Programming and Scripting | 4 | 02-20-2008 03:50 AM |
| how to numeric sort on field time | rahulspatil_111 | Shell Programming and Scripting | 1 | 04-27-2007 08:52 AM |
| How do I specify tab as field separator for sort? | SSteve | UNIX for Dummies Questions & Answers | 8 | 04-26-2005 01:39 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Sort - only one field appears in output?
I'm running against a file with 1008 records like this, all beginning '4760 Slave':
4760 Slave,7,3607 ,GL ,200605,11320024 , ,GBP ,X00033 ,AI80190 ,GBP,+,000000000015 370123, ,P , I'm running a sort, like this: sort +1 -9 -t, -o sorted_REPORT_200605_3607_GL_RECON REPORT_200605_3607_GL_RECON ...which *should* sort the comma-seperated file on fields 2-9, outputting it to "sorted_...." file... but the output file I get just contains: 4760 Slave 4760 Slave 4760 Slave etc... When it runs, I do see a message of: "sort: Warning: A newline character was added to the end of file REPORT_200605_3607_GL_RECON." Any help please? Where has the remainder of each record gone? If I 'vi' the file, it looks fine, but I have also noticed, if I 'head' the file, I see the same thing: 4760 Slave 4760 Slave 4760 Slave |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
I always surround my field separator with double quotes and specify all the fields that I want to sort on like this:
sort +0 +2 +4 +5 -t"|" infile.txt > outfile.txt +0 is the first field in the record, +1 would be the second. |
|||
| Google The UNIX and Linux Forums |