rsync提供了一些跟删除相关的参数
rsync –help | grep delete
–del an alias for –delete-during
–delete delete files that don’t exist on the sending side
–delete-before receiver deletes before transfer (default)
–delete-during receiver deletes during transfer, not before
–delete-after receiver deletes after transfer, not before
–delete-excluded also delete excluded files on the receiving side
–ignore-errors delete even if there are I/O errors
–max-delete=NUM don’t delete more than NUM files
其中–delete-before 接收者在传输之前进行删除操作
可以用来清空目录或文件,如下: