If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > sort on morethan 2 files

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-11-04, 12:48
markjason markjason is offline
Registered User
 
Join Date: Jun 2004
Posts: 46
sort on morethan 2 files

Hi all,

What is the unix sort command to sort 3 files x1.txt,x2.txt,x3.txt at the same time

where i have to do sorting on the 4 keys(columns) on the 3 files and these four columns are same on the 3 files


can any one help me how to do ?

Thanks
Jason.
Reply With Quote
  #2 (permalink)  
Old 07-11-04, 15:34
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
do you want to create ONE sorted fiile out of 3 input files?

what is your record/column separator?
what columns do you need to sort on?

man sort
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
  #3 (permalink)  
Old 07-11-04, 22:17
markjason markjason is offline
Registered User
 
Join Date: Jun 2004
Posts: 46
hi

i need to sort 3 files and put the result in the same 3 input files (overwrite)
three input files are comma delimited , i have tried on single key files but never on 4 key fields and on 3 files at a time....


thanks
jason
Reply With Quote
  #4 (permalink)  
Old 07-12-04, 09:06
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
I don't think you can do what you want without writting a script wrapper.
work out the details in the 'stand-alone' mode and write your script afterwards.

Here's how to sort on 2 fields: second and fifth:

sort -t ',' -k 2,2 -k 5,5 file
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
  #5 (permalink)  
Old 07-12-04, 09:27
markjason markjason is offline
Registered User
 
Join Date: Jun 2004
Posts: 46
Thanks vgresh,

I will try... what you said,... but i guess there is sort -o option to overwrite the same file...


Thanks
Jason
Reply With Quote
  #6 (permalink)  
Old 07-12-04, 09:57
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
right, but I don't think you can do it for multiple files. I might be mistaken - you'll have to try it out in the 'sand-box' to see how far you can get.

If you cannot do it for multiple files on the same command line, you'l' have to script it with some kind of a 'loop' - one file at the time.
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On