Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Linux folder and extract the differential file comparison techniques -rsync Magical     - Redis is installed in Ubuntu 14.04 (Database)

- Java multi-threaded shared communications variables (Programming)

- 2 minutes to read large data framework Hadoop and Spark similarities and differences (Server)

- Ubuntu root user profiles (Programming)

- Related to optimize the use of Btrfs file system on SSD (Linux)

- Linux the best download manager uGet (Linux)

- ctop: monitor container performance Linux command line artifact (Linux)

- C ++ Learning Notes: references (Programming)

- CentOS 7 Add yum source (Linux)

- DVD production using CentOS installation source within the company Yum (Linux)

- Linux uses shared memory communication process synchronization Withdrawal (Programming)

- How to configure a development environment elegant Lua (Linux)

- Talking about the shortcomings and deficiencies of the firewall (Linux)

- MySQL + Corosync + Pacemaker + DRBD build highly available MySQL (Server)

- Erase do with HTML5 Canvas and diffusion effect (Programming)

- Linux memory management -free learning experience (Linux)

- Vim Common Command Summary (Linux)

- for (int a: i) the use of the Java programming (Programming)

- What is the Docker (Linux)

- CentOS 5.11 Open VNC access (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.
- Intrusion analysis and prevention tools Knark under Linux platform (Linux)
- Compare Swift achieve rapid sorting and sorted Methods (Programming)
- OpenNMS separate database (Server)
- Ubuntu 14.04 installed VirtualBox 4.3 appears vboxdrv: Unknown symbol mcount (Linux)
- Eclipse installs support for Java 8 (Linux)
- mysql_config_editor encryption and decryption of the new features of MySQL realization (Database)
- Monitor traffic Linux Shell Edition (Programming)
- To install the mail client terminal Evolution 3.13.2 under Ubuntu 14.04 (Linux)
- Hibernate Performance Optimization of reusing SessionFactory (Programming)
- Simple comparison of MySQL and Oracle in a sql analytical details (Database)
- Linux virtual machines to solve end MySQL database can not remote access (Database)
- The callback function used in C ++ (Programming)
- Installation and Configuration ISC DHCP server on Debian Linux (Server)
- Getting Started with Linux: Learn how to upgrade Docker in Ubuntu (Server)
- Installation CD audio file extraction tool Flacon (Linux)
- C # / iOS / Android Universal Encryption and decryption (Programming)
- Linux VMware virtual machine after the cloning of the card can not start to solve (Linux)
- After Oracle 11g dataguard failover rebuild the archive logs are not applied to be NO problem (Database)
- Linux system security knowledge (Linux)
- VirtualBox snapshots (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.