i am looking for help for the below issue.

file1 has 2500 lines file2 has 500 lines

trying to list the words which are missing in file2 to compared to file1.

diff not working as these are huge files. tried comm -12 ..not listed anything in the output.

thanks in advance.

  • One word per line? – Hauke Laging Mar 20 '18 at 20:45
  • yes, its like one word lines in both files. – mytestresultsback didmy Mar 20 '18 at 20:51
  • Please provide an example of what the two files look like. You don't have to post the entirety of each file but just some of the lines so that there is a better idea of what you are trying to do. – Nasir Riley Mar 20 '18 at 20:54
  • file1: xxxxo_index_bin_primary xxxx_index_test_secondary_member xxxx_bots_test_primary_pool – mytestresultsback didmy Mar 20 '18 at 20:59
  • file 2: redfrog_bt redfrog_bt_ redfrog_socr these files has common words on similiar lines to above – mytestresultsback didmy Mar 20 '18 at 20:59

Without any performance consideration (could be improved if the lines are not unique):

grep -vxf file2 file1
  • i tried grep -vxVf .. did not gave me the output.. Let me try this.. – mytestresultsback didmy Mar 20 '18 at 21:03
  • @mytestresultsbackdidmy Why -V? But indeed I was missing the -x – Hauke Laging Mar 20 '18 at 21:09
  • i was checking the version to see if there is an issue.. without it , now i got something.. i will have to confirm with the list i got it correct or not.. thanks for helping on this.. – mytestresultsback didmy Mar 20 '18 at 21:13
  • if i add -x .. output writes all the matching whole lines.. i dont want it ,since i am looking for whats missing in file2 compared to file1. Your answer worked for me. thank you. – mytestresultsback didmy Mar 20 '18 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.