Find the answer to your Linux question:
Results 1 to 3 of 3
Hello everyone! I am fairly new to Linux and was needing some help on a comparing more than 2 files. I am try to come up with something that would ...
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    1

    Comparing multiple of files

    Hello everyone! I am fairly new to Linux and was needing some help on a comparing more than 2 files. I am try to come up with something that would compare at least 10+ different files to a master file and give me an output of what is missing.

    Example would be:

    a.txt, b.txt, c.txt, d.txt compare each of them to the master.txt file, than output the missing text for each file into new file.

    I came across comm and diff commands, am I looking in the right place or is there a much easier way of doing this?
    Any help would be greatly appreciated!

    -Rick

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    I think you would need to compare them one at a time,
    like
    a.txt and master.txt
    and write them into new file
    now check
    b.txt with master.txt and so on..

    To compare files I normally use Kompare
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  3. #3
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    955
    You could write a bash script to do it. The file names would be your arguments. Then you would need a loop something like:
    Code:
    for filename in $* do
    diff filename master.txt>>logfile
    done
    "I'm just a little old lady; don't try to dazzle me with jargon!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...