Compare two folders in Linux and do a tar (similar to rsync but using tar)

On machine1 (leopard)

find folder1/media -print > leopard_media.txt

On machine2 (panther)

find folder1/media -print > panther_media.txt

upload leopard_media.txt to panther, sort the files together, ready for uniq and tarring together.

cat leopard_media.txt panther.txt | sort | sed 's/^M//g' > both_media.txt

The sed command removes whitespace from the end of the lines - to get ^M do Ctrl+V then Ctrl+M

uniq -u both_media.txt > missing_media.txt

tar cvfz panther_media.tar.gz -T missing_media.txt

 

Leave a Reply