The UNIX and Linux Forums  
Hello and Welcome from to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 06:03 AM
sort columns by field kamel.seg Shell Programming and Scripting 4 02-20-2008 06:50 AM
how to numeric sort on field time rahulspatil_111 Shell Programming and Scripting 1 04-27-2007 12:52 PM
How do I specify tab as field separator for sort? SSteve UNIX for Dummies Questions & Answers 8 04-26-2005 05:39 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-24-2006
miwinter miwinter is offline
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
  #2 (permalink)  
Old 07-24-2006
jyoung jyoung is offline
Registered User
  
 

Join Date: Nov 2001
Location: Flint, MI
Posts: 228
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:24 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0