How to get rsync to not print directories
Solution 1:
I often use rsync to synchronise directory structures and like to do a dry run before running the actual command. I too get annoyed by the printing of the directory names so I use grep
to filter them out.
One difference between my usage and yours is that I use the --delete
option to remove files from the destination directory. Accordingly, I don’t want the grep
to filter out lines such as
deleting folderA/
deleting folderA/folderB/
Also, I like to keeps the blank line (^$
) for readability so the full pipeline is:
rsync -auvn --delete source_folder destination_folder | grep -E '^deleting|[^/]$|^$'
It’d be great if rsync
had a flag for not printing out directory names (it has an option for almost everything else) but in the mean time, this is the best hack I’ve come up with.
Solution 2:
I had a very similar problem, I was doing a dry-run and it was unnecessarily printing unmodified directories. I found --omit-dir-times
(in short -O
) which solved this.