Q:

Compare two files, print the first word which are unchanged in second file

I have fileA with following content:
12345:$gfdgfgfgfgfgfgfdgdgfgfdgfdg/:17436:0:99999:7:::
67890:$kjhwhkjhwekjrhwkejhwkjehkjl/:17433:0:99999:7:::
14567:$aaaaaaaaaaaaaaaaaaaaaaaaaaa/:17437:0:99999:7:::

I have fileB with the following content
12345:$gfdgfgfgfgfgfgfdgdgfgfdgfdg/:17436:0:99999:7:::
14567:$bbbbbbbbbbbbbbbbbbbbbbbbbbb/:17437:0:99999:7:::
67890:$ccccccccccccccccccccccccccc/:17433:0:99999:7:::

I want to compare fileA and fileB. If any lines in fileB are unchanged compared to fileA, then I want to print the first word of that line. 
So, the output should be just the following as per the example I have given above.
12345

I tried my luck with diff and comm. But, the lines in fileB may not appear in the same order as they appear in fileA.
Any help will be much appreciated.

A:

This awk one-liner should do the job:
awk -F':' 'NR==FNR{a[$0]=1;next}a[$0]{print $1}' fileA fileB

