how to compare two files in different directories

Hi all ,

Can any one give me the solution for below query.

I have two files .

firstfile:

xyz123
abc234
text2456

secondfile (\home\test)

xyz123:ram
ab34:scrit
text2456:maven

After you compare the ouput should the the common items in both files

Output : xyz123:ram
text2456:maven

Please reply .

ksk

Like this?

awk 'FNR==NR{a[$1];next}$1 in a' firstfile FS=: secondfile

Thanks for the reply . could you please explain me about the command , I haven't use awk actually .

I am a beginner in shell scripting as well.:slight_smile: