Fukkatsu
Fukkatsu

Reputation: 149

How to compare two directory's files (using file names only) in Linux?

I wanted to ask if there is a command in Linux that can check recursively for two folder's contents and generate an output of the differences.

What I need is a command that only compares the file name and structure of it and not the contents of each file. The reason for this is that I just backed up 2TB worth of data on different occasions and guarantee that all the data retained its integrity and have the same contents, but I want to check if I copied all the back-ups to see if I have missed one (It is hard to manually check 5000 folders).

Here is a little sample

/dir1 --> turtle.pdf banana_folder chicken.leg
/dir2 --> turtle.pdf banana_folder

I have used the diff command with the -qr and -r arguments but it takes too long just to traverse the files, which I feel it does not only check the structure and file name (Tested on a folder with 10 4GB files)

My limitations are that I can only use a command line since I cannot transfer the drive nor enter the GUI of the linux environment

Upvotes: 2

Views: 1303

Answers (1)

Pavel
Pavel

Reputation: 7552

you can just diff the lists obtained with find:

find dir1 | sort > list1.txt
find dir2 | sort > list2.txt
diff list1.txt list2.txt

Upvotes: 3

Related Questions