Good evening
I have the below requirements, as I am not an experts in Linux/Unix and am looking for your ideas how I can do this.
I have file called file1 and file2.
I need to get the second column which is text1_random_alphabets and find that in file 2, if it's exists then print the 3rd column which is 300 in file 1 as 4th column.
Sample file1
ID KEY Time
01 text1_random_alphabets 400
02 text2_random_alphabets2 350
03 text3_random_alphabets3 1000
Sample file2:
ID KEY Time
01 text1_random_alphabets 300
02 text2_random_alphabets2 250
03 text3_random_alphabets3 400
09 textn_random_alphabets33 400
Desired Output
01 text1_random_alphabets 400 300
02 text2_random_alphabets2 350 250
03 text3_random_alphabets3 1000 400
I have read the file1 and in a loop and then for each line grep it in file2 then create a new file with 3rd column. But that seems to be lot of parsing and number of execution would be more as files contains more than 250000 records.
I am sure it would be better solutions than I have, Is there any other solutions/approach which I should be implement?. Appreciate your time.