Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Linux folder and extract the differential file comparison techniques -rsync Magical     - Install the latest ATI / Nvidia graphics driver on Ubuntu (Linux)

- How to install and use the Snort in Ubuntu 15.04 (Linux)

- Linux file compression and file system packaged with instructions (Linux)

- Linux CPU Monitoring Index (Linux)

- xargs Detailed description (Linux)

- Monitor traffic Linux Shell Edition (Programming)

- How to use OpenVPN and PrivacyIDEA build two-factor authentication for remote access (Server)

- Differences Shell scripting languages and compiled languages (Programming)

- Use FFmpeg processing high quality GIF (Programming)

- Ubuntu 14.04 Nvidia graphics driver installation and settings (Linux)

- Some Linux networking tools you might not know (Linux)

- Linux-du and df command (Linux)

- Ganglia Python plug-in the process of writing notes (Linux)

- Oracle database, some basic grammatical structures (Database)

- MySQL database master never solve the synchronization method (Database)

- Configuring Allatori code confusion when developing general Java applications in NetBeans (Programming)

- Locale files under Ubuntu (Linux)

- Database Blob data type conversion String (Programming)

- Use matplotlib scientific drawing in Linux (Linux)

- Ubuntu users how to install the latest Nvidia graphics drivers (Linux)

  Linux folder and extract the differential file comparison techniques -rsync Magical
  Add Date : 2018-11-21      

Recently the team is developing a version of the comparison tool, the requirement is to A1 and A2 folder comparison, the incremental part A2, the output folder to update, upgrade package to generate incremental / differential subcontractors.


The first reaction is to implement this feature, each traversing two folders, perform a single file comparison exists in the MD5 comparison, and outputs the result, but this is definitely the lowest level approach, and the time complexity is O (n2), basic It is the direct negation.

Later, in-depth study of the kernel patch common diff + patch program, namely

diff -urNa dir1 dir2
After generating the differences between files, patch command to copy the contents of a file or file modifications. Obviously if you want to achieve this requirement is going to manual code parsing diff result of the job. Also complicated.

suddenly. . Or that similar cartoon scene inside Conan phrase masaka with flash effect appeared ...

Folders can analyze the differences, but also supports a variety of comparative mode checksum, mod-time, size, but also filter out binary svn not required to submit the intermediate file, often for incremental synchronization server, not that rsync it. . . (HERE times rsync should enlarge the font size, but not change markdown)

The only problem to be solved is, rsync is from A to B Folder Sync folder synchronized whether you can redirect the files to the C folder without changing the B folder content?

After going over rsync man oh ~ this --dry-run trial is to demonstrate the meaning of the parameters. . That is the use of dry-run can only look, not changed. . .
Immediately start coding. . .


A1.1 is a new folder, A1.0 is the old folder, out incremental file is placed to keep the directory structure of A1.0 to A1.1.

rsync --dry-run -rcnC --out-format = "% n" A1.1 / A1.0 /
Note that there is -C parameters in accordance with the cvs ignore rules to filter does not require synchronization of files in CVS, the default is not submitted binary file, so if you need to extract binary file, do not add C.
After executing the command, you get a list of files A1 directory:
A1.1 / system / app /
A1.1 / system / app / A.apk
A1.1 / system / app / B.apk
A1.1 / system / app / C.apk
That is the difference file, since the default will be displayed here to display the folder, so to filter out the "/" as the end of the folder

rsync --dry-run -rcnC --out-format = "% n" A1.1 / A1.0 / | grep -v "/ $"
So you get a list of pure delta files


With the list of files, copy the methods of operation on the lot. You can continue to use rsync to synchronize new catalog out to prevent the error file multiple times to fix the problem
Complete code

rsync --dry-run -rcnC --out-format = "% n" A1.1 / A1.0 / | grep -v "/ $" | xargs -I {} rsync -R A1 /./ {} out /

to sum up

In fact, we have a lot of common tools around, with powerful features. In fact, this group as a program ape, "impetuous" is a boundary to separate master and novice. In fact, many experts are not mastered the language, know the number of modes, a collection of many open source tools ...
But we need to get down each step.
- CentOS 6.5 opens the Xmanager Remote Desktop login (Linux)
- C # Future: Tracking null reference (Programming)
- Installation and use of Linux Sniffer tool Tcpdump (Linux)
- Oracle 11R2 Grid Infrastructure execute root.sh script rootcrs.pl execution failed treatment (Database)
- Free compiler install MySQL-5.6.14 (Database)
- ORA-01000 Solution (Database)
- Java open source monitoring platform Zorka basic use (Linux)
- Java, extends and implements Usage (Programming)
- JDK tools jstat (Linux)
- Installation Strongswan: on a Linux IPsec-based VPN tool (Linux)
- CentOS7 install JAVA notes (Linux)
- 11.2.04 Oracle RAC directory crfclust.bdb file is too large, Bug 20186278 (Database)
- To install Ganglia configuration of experience under CentOS 5.5 (Linux)
- Php and MySQL command add to the environment variable method in Linux system (Linux)
- 10 useful Linux command line tips (Linux)
- Linux-- sub-volume compression and decompression (Linux)
- MySQL Parameter Tuning Best Practices (Database)
- Linux, Chrome browser font settings beautification (Linux)
- Ubuntu 14.04 Enable root and disable the guest (Linux)
- Linux, Apache Web site security settings (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.