Rsync options for getting info like how many files deleted in email

Solution 1:

Some of that information will be output by the --stats option.

You can use the command below to count the deleted files. It also suppresses the output of the copied filenames. You may need to modify it to match the output of your particular rsync option selection. I've included a simple rsync command as an example. Note that the --stats and --verbose options are required for this to work.

rsync --archive --delete --stats --verbose from to | \
awk 'BEGIN {count = flag = 0} \
    /^deleting/ {count++; next} \
    /^Number of files: [0-9]*$/ {flag=1; print "Files deleted: " count} \
    {if (flag == 1) {print}}'