[Linux general] copy diff of 2 folders to a separate folder

Thomas Kaiser ubuntu at kaiser-linux.li
Wed Mar 10 22:25:20 UTC 2010


On 03/10/2010 11:03 PM, Brian McKee wrote:
> On Wed, Mar 10, 2010 at 2:08 PM, Thomas Kaiser <ubuntu at kaiser-linux.li> wrote:
>> When I diff to folders, I get a output like this:
>> Only in /var/www/images/stories/fruit: ABS.jpg
>>
>> Now, I would like to copy the "Only in" to a different folder (with full
>> path name, if possible).
> 
> 
> ugly as sin, but I suspect works (untested!)
> 
> diff -rq folder1 folder2 | awk -F ': ' '{print $2}' > listOfFilesToCopy.txt

That's good. I get a text file which shows me all files that have changed.

> for ITEM in $(cat listOfFilesToCopy.txt) ; do cp -v "$ITEM" outputFolder ; done
This doesn't work because the full path name is missing.
Anyway, with the above command I get my thing done!

Thanks, Thomas





More information about the ubuntu-users mailing list