compare fields in different files

HI

I'm having some troubles to compare and permut diffrent fields indexed with another filed like the following example `:

file1

1 1
2 2
3 3
file2

7 1
9 2
10 3

result-------------------

file1

7 1
9 2
10 3
file2

1 1
2 2
3 3

thanks in advance

man join (linux) might do what you need. Now to make it clearer, I changed file1 to:

A 1
B 2
C 3

So with join, you get:

$ join -j 2 file1 file2 
1 A 7
2 B 9
3 C 10

You can use man awk (linux), man sed (linux), man cut (linux), or many other commands to trim off the first field:

$ join -j 2 file1 file2 | cut -d' ' -f2-
A 7
B 9
C 10

sorry I guess there is misunderstanding here, I want to take the maximun value in the first field (first column) indexed whith the second colomn. file1 must have those max values. here is another example

file 1

6   1
7   2
8   3

file 2

3   1
9   2
10  3

after processing file 1 become

file 1
6   1
9   2
10   3

and file2

file 1
3   1
7   2
8   3

I guess it's clear enough thank you again for your effort

I have no idea what you are trying to do. What is being indexed? Please give a verbal description of your process, or something.

What i want to do is to compute a max number within element sharing the same index and to put that max in file 1 and 2 second max in file2 etc

in other way sorting the elements having the same index and afecting the first element in the first file (with its index) second element in the second file ....
if that clear enough?

Hi all !

I guess, I understand the question, I've put the 'index' in the first column

soy@machine: temporal > cat uno.txt
1 4
2 8
3 9
4 1
soy@machine: temporal > cat dos.txt
1 2
2 6
3 4
4 9
soy@machine: temporal > join uno.txt dos.txt
1 4 2
2 8 6
3 9 4
4 1 9
soy@machine: temporal > join uno.txt dos.txt > unidos.txt
soy@machine: temporal >  awk '{ if( $2 >= $3){ print $1, $2 }; if ( $3> $2){ print $1, $3}}' unidos.txt
1 4
2 8
3 9
4 9

best regards

hi maya_style

it's exactly what I want to do ! except one detail

If i want to redirect the result to a file I will do like that

awk '{ if( $2 >= $3){ print $1, $2 }; if ( $3> $2){ print $1, $3}}' unidos.txt >> result_file

but I want also to redirect the rest of the temporal file file to another file eg :

another file : 
1 2
2 6
3 4
4 1

thanks a lot