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

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


sort -k 1b,1 flash_int_list.txt | join finish_comm - > t1
  • 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

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.


You'll often see join used with process substitution

join finish_comm <(sort flash_int_list.txt) > t1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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