0

I have 2 directories , dir1 and dir2.

There are some directories in them. Suppose dir1 has a,b and c directories and dir2 has c,d and e.

I need a script that will find out the duplicate directories in dir1 and dir2,in this case, "c" and log it into a separate file,say,duplicate.lst.

6055
  • 439
  • 1
  • 4
  • 14
  • This is not a question. – John C May 19 '14 at 13:03
  • Why? I am asking for a script that finds the duplicate. Why is this not a question? – 6055 May 19 '14 at 13:33
  • @6190 Because "I need to ..." is not a question, it's a statement. Show us what you've tried and how it's not working, and ask a specific question about the problem you've encountered. – twalberg May 19 '14 at 15:59

1 Answers1

0
DIR1=dir1
DIR2=dir2

## find all subdirectories of `dir1` by using subdir/. and loop
for SUB in `cd $DIR1; echo */.`
do
     ## for each check if it exists in $DIR2
     if [ -d $DIR2/$SUB ]; then
          echo "Duplicate: "`dirname $SUB`
     fi
done
Ingo Leonhardt
  • 9,435
  • 2
  • 24
  • 33