Reputation: 33
I need to write a C program for finding the differences between two folders, folder1 and folder2.tar and update the contents of folder2.tar with folder1. So I have written using tar --diff utility command like below:
#include <unistd.h>
#include <stdio.h>
main()
{
system("tar df folder2.tar folder1 > file.patch");
system("tar uf folder2 folder1"); //Assume folder2 is the extracted version of folder2.tar
}
Here I have few questions:
Any idea !!!!! Please help me if you have so ! Thanks
Upvotes: 0
Views: 292
Reputation: 50210
Try this:
tar xf folder2.tar
diff -rq folder1 folder2
You can then get the modified filenames from the output of diff and pass them to tar -u
. Feel free to wrap it in system() so you can call it a C program, but I'd advise you to make it a bash script: Smaller, faster and you don't need to recompile when you make changes.
Upvotes: 1