I want to join two files according to number in the file, two number same file
Toyota model1
BMW model2
Benz model3
BMW model4
BMW model5
Benz model6
Benz model7
and second file
class C model1
class E model2
class A model3
class W model4
class W model5
class C model6
class A model7
I want to join the two file according to the number, like this, joining each model number with each other in one file.
Toyota class C model1
BMW class E model2
Benz class A model3
BMW class W model4
BMW class W model5
Benz Class C model6
Benz Class A model7
after that delete the 'model' string
My code,
sort -V file1 > new_file1
sort -V file2 > new_file2
join newfile1 new_file2 > result.txt
sed 's/model[(1-9)]//g' result.txt > result_1.txt
the problem I'm getting an Error while joining the files
join: file1.txt:10: is not sorted: 03Benz model 249
join: file2.txt:4: is not sorted: BMW model 2
what if I want to count frequency after that
( this pair happen in the text 2 times) after joined
Toyota class C 1
BMW class E 1
Benz class A 2
BMW class W 2
Benz Class C 1