1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Directory compare script

Discussion in 'Linux & Open Source' started by Berserker, 26 Feb 2006.

  1. Berserker

    Man of Honour

    Joined: 4 Nov 2002

    Posts: 15,454

    Location: West Berkshire

    Does anyone know of a Linux script/utility/whatever to compare all the files in two directory structures and list what's different. When I was working with *nix at work, I had one, but I've long since lost that. :(

    Suggestions gratefully recieved. :)
     
  2. whitecrook

    Sgarrista

    Joined: 22 Aug 2005

    Posts: 8,389

    Location: Clydebank

    cd dir1
    ls -R > ~\dir1.txt
    cd dir2
    ls -R > ~\dir2.txt
    cd ~
    diff dir1.txt dir2.txt


    or something that effect should do for quick n dirty
     
  3. Mpemba Effect

    Man of Honour

    Joined: 18 Oct 2002

    Posts: 7,097

    Or simply
    Code:
    diff <dir1> <dir2>
    :D or
    Code:
    diff --brief <dir1> <dir2>
    might give a more friendly output.
     
  4. Kona*

    Wise Guy

    Joined: 29 Dec 2003

    Posts: 2,039

    Location: Newcastle upon Tyne

    I needed to do this last week too, a bit late now but I know for the future - cheers!

    Oooh, and welcome back Mpemba Effect! I havent seen you around in ages!

    Cr4iG
     
  5. Berserker

    Man of Honour

    Joined: 4 Nov 2002

    Posts: 15,454

    Location: West Berkshire

    Yup. Indeed. Nice to see you around again.

    PS. Add --recursive to the above and we're on to a winner. Didn't know diff could do this. :)