Bluehost.com Web Hosting $6.95

Listing changed files between directories

This is a discussion on Listing changed files between directories within the Linux General forums, part of the Linux Forums category; I have two directories: /home/rose_garden/abs/core and /var/abs/core they both contain directories like this acl/ +-----PKGBUILD ...


Go Back   Usenet Forums > Linux Forums > Linux General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-30-2008
Baho Utot
 
Posts: n/a
Default Listing changed files between directories


I have two directories:

/home/rose_garden/abs/core and /var/abs/core

they both contain directories like this

acl/
+-----PKGBUILD
atl2/
+-----PKGBUILD
etc

/var/abs/core is rsynced from ArchLinux repos.
and /home/rose_garden/abs/core is my work area.

When Arch changes or updates the PKGBUILD file I would like to get a list of
changed files so I can rebuild my files based in /home/rose_garden/abs/core
Simply rsync between the two directories won't work as I need to make some
changes before using the "new/updated" PKGBUILD file.

I would also like to include any new files that don't reside
in /home/rose_garden/abs/core but are in /var/abs/core as they represent
new software packages placed into the repos.

I would like the list to contain only the files that where updated or
changed.

Comparing
/var/abs/core/acl/PKGBUILD to /home/rose_garden/abs/core/acl/PKGBUILD
and if /var/abs/core/acl/PKGBUILD changes place an entry into a file as in
/var/abs/core/acl/PKGBUILD updated or something similar.

I tried diff but it did not work out as there was too much data I am looking
for just a simple list.

Thanks

Reply With Quote
  #2 (permalink)  
Old 08-30-2008
pk
 
Posts: n/a
Default Re: Listing changed files between directories

On Saturday 30 August 2008 14:53, Baho Utot wrote:

>
> I have two directories:
>
> /home/rose_garden/abs/core and /var/abs/core
>
> they both contain directories like this
>
> acl/
> +-----PKGBUILD
> atl2/
> +-----PKGBUILD
> etc
>
> /var/abs/core is rsynced from ArchLinux repos.
> and /home/rose_garden/abs/core is my work area.
>
> When Arch changes or updates the PKGBUILD file I would like to get a list
> of changed files so I can rebuild my files based in
> /home/rose_garden/abs/core Simply rsync between the two directories won't
> work as I need to make some changes before using the "new/updated"
> PKGBUILD file.
>
> I would also like to include any new files that don't reside
> in /home/rose_garden/abs/core but are in /var/abs/core as they represent
> new software packages placed into the repos.
>
> I would like the list to contain only the files that where updated or
> changed.
>
> Comparing
> /var/abs/core/acl/PKGBUILD to /home/rose_garden/abs/core/acl/PKGBUILD
> and if /var/abs/core/acl/PKGBUILD changes place an entry into a file as in
> /var/abs/core/acl/PKGBUILD updated or something similar.
>
> I tried diff but it did not work out as there was too much data I am
> looking for just a simple list.


I assume that by "changed" you mean "having different hash" or something
like that. Try this:

#!/bin/bash

export H=/home/rose/garden
export V=/var

find "$V/abs/core" -type f -name PKGBUILD -exec bash -c '
m1=$(md5sum "$1"|cut -d " " -f1)
m2=$(md5sum "${1/#$V/$H}"|cut -d " " -f1)
if [ "$m1" != "$m2" ]; then
echo "$1 updated"
fi' sh '{}' \;

Reply With Quote
  #3 (permalink)  
Old 08-30-2008
Baho Utot
 
Posts: n/a
Default Re: Listing changed files between directories

pk wrote:

> On Saturday 30 August 2008 14:53, Baho Utot wrote:
>
>>
>> I have two directories:
>>
>> /home/rose_garden/abs/core and /var/abs/core
>>
>> they both contain directories like this
>>
>> acl/
>> +-----PKGBUILD
>> atl2/
>> +-----PKGBUILD
>> etc
>>
>> /var/abs/core is rsynced from ArchLinux repos.
>> and /home/rose_garden/abs/core is my work area.
>>
>> When Arch changes or updates the PKGBUILD file I would like to get a list
>> of changed files so I can rebuild my files based in
>> /home/rose_garden/abs/core Simply rsync between the two directories won't
>> work as I need to make some changes before using the "new/updated"
>> PKGBUILD file.
>>
>> I would also like to include any new files that don't reside
>> in /home/rose_garden/abs/core but are in /var/abs/core as they represent
>> new software packages placed into the repos.
>>
>> I would like the list to contain only the files that where updated or
>> changed.
>>
>> Comparing
>> /var/abs/core/acl/PKGBUILD to /home/rose_garden/abs/core/acl/PKGBUILD
>> and if /var/abs/core/acl/PKGBUILD changes place an entry into a file as
>> in /var/abs/core/acl/PKGBUILD updated or something similar.
>>
>> I tried diff but it did not work out as there was too much data I am
>> looking for just a simple list.

>
> I assume that by "changed" you mean "having different hash" or something
> like that. Try this:
>
> #!/bin/bash
>
> export H=/home/rose/garden
> export V=/var
>
> find "$V/abs/core" -type f -name PKGBUILD -exec bash -c '
> m1=$(md5sum "$1"|cut -d " " -f1)
> m2=$(md5sum "${1/#$V/$H}"|cut -d " " -f1)
> if [ "$m1" != "$m2" ]; then
> echo "$1 updated"
> fi' sh '{}' \;


Thanks I will try this


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:24 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0