I have a file lets say file1.txt
ENSG00000223116 AL157931.1 ENSG00000233440 HMGA1P6 ENSG00000207157 RNY3P4 ENSG00000229483 LINC00362 ENSG00000252952 RNU6-58P
I have another file say file2.txt
ENSG00000223117 0 0 ENSG00000223116 0 0 ENSG00000233440 1.71449394 50
I want to compare file1 with file2 for ENSG names and get the output such that if ENSG name in file 1 is present in file2 then output should be
ENSG00000223116 0 0 AL157931.1 ENSG00000233440 1.71449394 50 HMGA1P6
I can write a perl script for this but I just want to do this on command line. How can it be done?