Help needed to validate and merge Two files

Hi.. I am new to unix !!!
Please help me in combining two files by validating the first column.
The files are tab limited !!!

I have a file which has the following contents...
DEPT1_BABYCARE 20 abce
DEPT2_PHARMACY 50 cdgde
DEPT3_WOMENS 75 jasjjas

I have another file which has the following contents
DEPT1_BABYCARE 30 50
DEPT2_PHARMACY 70 90
DEPT4_GROCERY 90 99 ( This line has to be removed as its not available in first file)

Now I have to combine both the files...
DEPT1_BABYCARE 20 abce 30 50
DEPT2_PHARMACY 50 cdgde 70 90
DEPT3_WOMENS 75 jasjjas NA NA

Please help ...

Please search the forums first - there're numerous of similar threads.

I am Unable to find a thread that suits my requirement... I want to validate a column and then merge... Please help...

Check this thread. It does what you want it to do

Thanks Joe.... But this thread doesnt suit my requirement.. i tried it. Please help.....

-----Post Update-----

somebody
Please help...

You could use the join command like this

 
join -a 1 -1 1 -2 1 -t" " -o 1.1 1.2 1.3 2.2 2.3 file1 file2

If this is going to be routine, you are probably far better off using a database, also considering your data is tab delimited. Databases are more robust, especially when files get big. In such case, the problem boils down to reading in your data and getting the SQL for selection right.

Thanks Joe...
I tried using join command as follows
join -a1 file.txt file.txt
and i got the output in the way i wanted.... except the tab delimitation is gone..... :frowning: