In O & M, sometimes we need to delete large files, or N (N is infinite ~~) Multiple small files
So, rm,
Here, Rocky introduces the most cute, gentle, mature, kind and kind of Linux in history.
This is another method of rsync.
① Syntax:
# Rsync -- delete-before-avH -- progress -- stats DEST SRC
Explanation:
When SRC and DEST are both objects [f], this indicates clearing the object content rather than deleting the object.
When SRC and DEST are both directories [d], it means to delete all files in the directory and change it to an empty directory.
PS: in fact, this command is very memorable, such as av-_-#, H $ _ $, cool, who are your hard drive at this time ,,
② Principle:
Rsync actually uses the replacement principle
③ Advantages:
Processing speed is quite fast. Processing Several GB of files is a matter of seconds, which is much faster than rm.
④ Disadvantages:
High Disk io usage, business peaks, or temporary avoidance
⑤ Test:
[Root @ localhost log] # ls
Rhel-server-5.8-i386-dvd.iso
[Root @ localhost log] # pwd
/Tmp/test/log
[Root @ localhost ~] # Mkdir empty
[Root @ localhost ~] # Rsync -- delete-before-avH -- progress -- stats/root/empty // tmp/test/log/
Building file list...
1 file to consider
Deleting rhel-server-5.8-i386-dvd.iso
./
Number of files: 1
Number of files transferred: 0
Total file size: 0 bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 19
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 29
Total bytes encoded ed: 15
Sent 29 bytes encoded ed 15 bytes 6.77 bytes/sec
Total size is 0 speedup is 0.00
Recommended reading:
Complete rsync synchronization Configuration
Use rsync to synchronize files between Windows and Linux machines
Rsync + inotify combined synchronization Solution
Real-time backup configuration of Rsync and inotify files
Explanation of Rsync usage skills and permissions in CentOS 5.5