Bash sort and join problems

2

I have to join two files. Firstly, I use commant sort and made two new sorted files. Next I use join, but it doesn't work. My script:

sort  -t ',' -r -k 4,4 file1.csv > sortf1.csv
sort  -t ',' -r -k 1,1 file2.csv > sortf2.csv
join -t ',' -1 4 -2 1 sortf1.csv sortf2.csv > last.csv

And error:

join: sortf1.csv:7: is not sorted: df-77,I,red,6674,6
join: sortf2.csv:4: is not sorted: 1967,XS,34,nf-54

diego9403

Posted 2015-08-17T09:11:00.640

Reputation: 807

Maybe join doesn't understand reversed sorted files? Try without it, you can always do a sort -r last. – Nifle – 2015-08-17T11:14:47.817

Join should understand. There are some lines in output file (last.csv). I tried use my script on the others files (created by me) and it work. – diego9403 – 2015-08-17T14:33:09.650

Show sample input and your desired output for that sample input. – Cyrus – 2015-08-23T10:06:27.973

file 1:(; is break line) nb-26,IV,red,3630,5; pv-63,IV,yellow,6303,2; sj-90,IV,blue,1957,2;

file 2: 1951,XL,95,zw-13; 1972,M,48,zt-67; 1991,M,72,ok-15; last: df-77,1944,S,75,II,blue,1911,2; df-77,1944,S,75,III,blue,3279,6; df-77,1944,S,75,II,violet,5080,1; df-77,1944,S,75,I,red,6674,6; – diego9403 – 2015-08-23T14:12:08.717

No answers