outer join in unix with 2 files

I've 2 files :

file1
-----
496223224
497448063
497425608
497440502

file2
-----
A 20212 497448063
B 12141 497425608
C 18745 497440900

I'd like to have :

result_file (only record from file2 and not in file1)
-----------
C 18745 497440900



Thx in advance,
Yassin
yahrikaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

liddlerCommented:
Think this will work:

#!/bin/ksh
cat /dev/null > diff_file
{ while read LINE
do
awk "/${LINE}/ {print }" file2 >> diff_file
done
} < file1
comm -23 file2 diff_file >result_file


Tested it on solaris, but should be generic
0
ellesdCommented:
I'm not sure if the comm command will work since the lines in both files are complete different.  However, this short script will create the desired result_file:

cp file2 result_file
exec 3< file1
while read N <&3
do
  grep -v $N restult_file > tmpfile$$
  mv tmpfile$$ result_file
done
rm -f tmpfile$$

The last line (rm -f tmpfile$$) is not really needed, but I put it in as a safeguard.

Try it out and let me know.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yahrikaAuthor Commented:
1st solution:

When i try with a big file test seems won't work
file2 --> 1763 record
file1 --> 226 record

diff_file --> 7060 records
result_file --> 0

2nd Solution :
When i try this --> error message (grep: can't open restult_file)



Help me please
0
ellesdCommented:
Sorry, I misspelled it.  Just change it to result_file.
Again, I appologize.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.