Wael hamadeh
Wael hamadeh

Reputation: 785

bash script to get files from a dir and compare them with another dir

suppose i have a Dir1 with only files ( t1.txt, t2.txt, t3.txt) how can i get a list of the files name only in a bash script that allows me to compare it to another list of files in Dir2 and find the missing files without using rSync

Upvotes: 1

Views: 512

Answers (1)

twm
twm

Reputation: 1458

diff -r --brief Dir1 Dir2

will tell you the differences between two directories, including when one directory contains a file that the other one doesn't. Incidentally, it will also tell you if Dir1 and Dir2 both contain a files with the same name, say t1.txt, but with different contents. It won't print files that are the same between the two directories.

Upvotes: 1

Related Questions