Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
sort flash_int_list.txt|join finish_comm - > t1
join: file 2 is not in sorted order

I have sorted flahs_int_list.txt but it still says file 2 is not in sorted order what is wrong ?

the flash_int_list.txt is like(just the first 2 lines are shown,it has mearly 1000 lines):

1     8cvGIKL7C-M   1  1         1         0    0    0    0  -28
9     27ugSKW4-QQ   1  3         3         0    0    0    0  -28
share|improve this question
1  
knowing the contents of format of the files would be helpful –  h3rrmiller Nov 16 '12 at 15:31
    
but I used "sort" on the file, it doesn't help? –  wenzi Nov 16 '12 at 15:45

3 Answers 3

You'll often see join used with process substitution

join finish_comm <(sort flash_int_list.txt) > t1
share|improve this answer

The -1 FIELD -2 FIELD options of join define which field of each file to be joined on. The default join field is the first, delimited by whitespace.

And the -k option of sort defines which key to be used to sort. If no key is given, use the entire line as the key.

So make sure which fileds you want to join on and the two files have sorted on those fileds.

See man join man sort for details.

share|improve this answer

Unfortunately, the man page says that sort <no options> | join <no options> doesn't work:

   Important: FILE1 and FILE2 must be sorted on the join fields.  E.g.,
   use ` sort -k 1b,1 ' if `join' has no options, or use ` join -t '' ' if
   `sort' has no options.

So you could try:

sort flash_int_list.txt | join -t '' finish_comm - > t1

or:

sort -k 1b,1 flash_int_list.txt | join finish_comm - > t1
share|improve this answer
    
what does 1b,1 mean? –  wenzi Nov 18 '12 at 21:26
    
What does the man page say about -k and POS? –  Mikel Nov 19 '12 at 4:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.