Yesterday, at the office, we had a client come to use needing to merge two 20 Gig directories of data together. Naturally I chimed in saying "I'm sure Linux can do that with a simple shell script"! Of course neither the client or my fellow workers wanted to deal with a shell script. So, instead, I decided to go the GUI route with a front-end for a tool that is an rsync-like folder, file synchronization tool. It can do much more than we were looking for it to do, but in the end it would do the trick just fine.
In this article I am going to show you how to install and use unison-gtk to merge a pair of local folders on a Linux machine. It will make for a simple example of how this tool can be used for remote folder synchronization, which holds countless uses.
Naturally you will want to know what features unison-gtk offers. Let's take a look:
Unison-gtk might not have the most lengthy feature set, but this tool is incredibly handy never the less. Now let's get on with the action.
Let's install this both using command line and Add/Remove Software. First, command line. To install unison-gtk do the following:
That's it. Now, let's look at the GUI steps.
That's it. You now have unison-gtk installed. You will find the menu entry in Applications > Accessories.
Using unison-gtk might seem tricky at first. It's not. You just have to pay close attention to which folders are which. I am going to demonstrate this tool using two folders: TEST and TEST2 (both residing in my users ~/ directory).
When you first fire up unison-gtk it is going to ask you to create a profile. What this profile is really doing is asking you to select the directories you want to sync. You will select the first and then you will select the second. When you come to setting up the second directory you will see (as shown in Figure 1) that you can set this up for remote synchronization via SSH, RSH, or Socket. You can create more profiles after you have walked through the "first run wizard" as well. For the sake of this article we are going to stick with local folders.
When your profile is complete unison-gtk will open with your two folders ready (see Figure 2). Pay close attention to how unison-gtk lays out the folders. Both folders are listed in what appears to be a header listing. Where the folders are is important as this will not change. What will change is how unison-gtk indicates what has changed in the folders. Say, when you first fire this up, both folders are in sync. Immediately unison-gtk will check the differences in the folders and let you know what they are. In my current test folders (which have already been sync'd) I have three files: test, test2, test3. Now, let's say I add the file test4 to the TEST directory. When that happens, if I hit the Restart unison-gtk will indicate to me a new file has been found in the TEST directory (see Figure 3).
In order to sync these two folders I have to pay close attention to which way the sync occurs. The way my profile is set up TEST is on the left and TEST2 is on the right. My new file is in TEST so it's on the left. As you would then expect, this sync needs to go LEFT TO RIGHT. Make sure the Action arrow is point in the right direction. If, for example, it were going in the wrong direction unison-gtk would assume you wanted the file erased.
After you are sure the arrow is facing the right direction click the Go button and unsion-gtk will do it's job. You should now have all four files in both TEST and TEST2. Very simple.
Of course unison-gtk is much more complex than what I have illustrated. But what you have seen here is how easy it can be to merge the contents of two directories on a Linux machine. And in case you are wondering, there is a Windows version of unison-gtk which can be found here.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats (video ads) or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.