Looking for script to compare entries of new file(File2) in already existed file F1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tvnaidu
    Contributor
    • Oct 2009
    • 365

    #1

    Looking for script to compare entries of new file(File2) in already existed file F1

    I am looking for script to compare a new entry from File2 in File1:

    I have Two files, once file (File1) contains e-mail ids which are already sorted and another file (File2) contains new e-mail ids received, I want to see if those ids (File2) are already existed in file1. Can I get a shell script or program for that?

    File1:
    xyz1@email.com
    xyz2@yahoo.com
    xyz3@gmailcom


    FILE2:
    abc@gmail.com
    abc1@gmail.com

    I want to insert all FILe2 entried into File1, if entry exists in File1, then I want to ignore.
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    You can use the "diff" command. Type diff --help or man diff.

    Comment

    • tvnaidu
      Contributor
      • Oct 2009
      • 365

      #3
      The first file (FILE1) contains atleast 1500 entries, second file (File2) contains only 100 entries, If I merge second file into first one, I might have duplicate entries, I want to read one one entry from second file (File2) and compare that entry against first file, if that entry doesn't exist, then I wanto to insert that entry intyo first one, like that all entries in second file should get verified, if not there, then insert that entry into first one.

      Comment

      • RedSon
        Recognized Expert Expert
        • Jan 2007
        • 4980

        #4
        Then you want to use "diff" and "patch" in your script. First you diff, then you apply that diff on the other file with patch.

        Comment

        Working...