according to linuxnote.net's webarchive is rsync -aP –delete empty/ ./dir
the fastest way to delete large directories, about three times faster as with rm -rfv ./dir
or with find b/ -type f -delete
since it can take a while, a verbose output with -P
is convenient or you gaze at an empty prompt line for ever...
and in order to avoid endless scrolling, I redirected the STDOUT to awk
to display the output on a single line (with a line counter) like this:
rsync -aP --delete ./emptyDir/ ./dir/ | awk ' { printf ( "\r #%4d: %-200s", NR, $0 ) } '
for skipping the Permission denied lines, use sudo:
sudo rsync -aP --delete ./emptyDir/ ./dir/ | awk'{printf("\r #%4d: %-200s",NR,$0)}'
explanation: awk
because printf
alone doesn't catch STDOUT, \r
to set the cursor at the begin of the output line, NR
for a line# counter and %4d
right-pads the line# and %-200s
for an output string of 200 chars right padded that overwrites the previous line (200 if terminal window has at least this width)