The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-24-2006
Registered User
 

Join Date: Jul 2006
Posts: 18
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
Reply With Quote
Forum Sponsor
  #2  
Old 07-24-2006
Registered User
 

Join Date: Nov 2001
Location: Flint, MI
Posts: 186
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0