Published 2022-12-01.
Time to read: 1 minutes.
I've been reorganizing directories across several volumes on an Ubuntu server.
This article documents how I used the commands I found to be most useful:
rsync
,
ncdu
,
and fdupes
.
The latter two programs are not installed by default.
You can install them this way:
$ yes | sudo apt install fdupes ncdu
Display Directory Sizes
$ ncdu /directory
Find Duplicate Files
This displays duplicate files and interactively asks which duplicate files to delete.
$ fdupes -r1Sd /directory
Compare Two Folders For Missing Files
This tip was inspired by an answer on
unix.stackexchange.com
.
Dry Run
The -n
option displays the names of missing files in the destination directory,
but makes no changes to the destination file system.
If that option is not specified, then the missing files are copied.
$ sync -ri --ignore-existing -n /srcDir/ /destDir
There are a few things to note:
- The first directory is the source, and it must end with a slash (/).
- The second directory is the target, and it must NOT end with a slash.
Copy Missing Files
Simply do not provide the -n
(dry run) option:
$ rsync -ri --ignore-existing /srcDir/ /destDir