[ale] Stumped-

Dennis Ruzeski denniruz at gmail.com
Mon Mar 15 12:16:14 EDT 2010


Thank you, All!
Although all the examples presented some good ways to do this, I went
with a modified version of Dave W's script-
It doesn't generate a bunch of temp files and seems to work pretty
quickly and was easily adaptable- I easily made another version that
takes 2 directories as arguments and put it in my function library.


#!/bin/bash
basedir=/path/to/client/dirs
# Client names are integer values, so only get those listings-
for dir in $basedir/[123456789]*
do
 cd $dir/movies 2>/dev/null
  for gfile in $(ls)
  do
   if [ -f $dir/images/$gfile ]
   then
    if [ $(stat --format=%s $gfile) -ne $(stat --format=%s ../images/$gfile) ]
    then echo The file $gfile for client $(echo $dir | awk -F/ '{print
$7}') has different sizes in movies and images
    fi
   fi
  done
done


On Fri, Mar 12, 2010 at 3:14 AM, Richard Bronosky <Richard at bronosky.com> wrote:
> I've wrote a very functional script for you here:
> http://gist.github.com/330096
>
> I still feel that, David A. De Graaf and others have noted, your needs still
> aren't completely clear. So, instead of continuing to try to get solid
> specification out of you, I figured I give you something to try out and then
> you would likely realize what needs to be changed. I broke it down and
> documented it so you can modify it to meet your needs. But please give it a
> try. It's got a built in demo that generates its own test data. All you have
> to do is use it as described below and give me feedback.
>
> You can see it in action by copying and pasting this in your shell:
> wget
> http://gist.github.com/raw/330096/0ca31670b30d344515bb39fae2f9c75b59c18392/compare_script.sh
> chmod +x compare_script.sh
> awk '/BEGIN UNIT TEST/{p=1};p==1{print}' compare_script.sh | bash
>
> This is the output you would see:
> ~$ wget
> http://gist.github.com/raw/330096/0ca31670b30d344515bb39fae2f9c75b59c18392/compare_script.sh
> --2010-03-12 02:05:49--
>  http://gist.github.com/raw/330096/0ca31670b30d344515bb39fae2f9c75b59c18392/compare_script.sh
> Resolving gist.github.com... 207.97.227.243
> Connecting to gist.github.com|207.97.227.243|:80... connected.
> HTTP request sent, awaiting response... 200 OK
> Length: 3273 (3.2K) [text/plain]
> Saving to: `compare_script.sh'
>
> 100%[===========================================================================================================>]
> 3,273       --.-K/s   in 0.03s
>
> 2010-03-12 02:05:50 (115 KB/s) - `compare_script.sh' saved [3273/3273]
>
> ~$ chmod +x compare_script.sh
> ~$ awk '/BEGIN UNIT TEST/{p=1};p==1{print}' compare_script.sh | bash
> Creating client directories in /tmp/ for testing...
> Removing /tmp/client01 /tmp/client02 /tmp/client03 /tmp/client04
> /tmp/client05 /tmp/client06 /tmp/client07 /tmp/client08 /tmp/client09
> /tmp/client10
> Create a dir structure to prove that it works on deep dirs
> Create 10 files in each dir
> Copy the images dir over to a movies dir
> Remove a file from each of the images dirs
> Remove a different file from each of the movies dirs
> Put some alternate data in to create non-matching filesizes
> Create 10 /tmp/clients (they'll all be the same, but you get the point)
> Run the script on all client directories
>
>
> /tmp/client01/images/landscape/asset03.ext
> /tmp/client01/images/landscape/asset04.ext
> /tmp/client01/images/landscape/asset06.ext
> /tmp/client01/images/landscape/file03.ext
> /tmp/client01/images/landscape/file04.ext
> /tmp/client01/images/landscape/file06.ext
> /tmp/client01/images/landscape/thumbnails/thumbnail03.ext
> /tmp/client01/images/landscape/thumbnails/thumbnail04.ext
> /tmp/client01/images/landscape/thumbnails/thumbnail06.ext
> /tmp/client02/images/landscape/asset03.ext
> /tmp/client02/images/landscape/asset04.ext
> /tmp/client02/images/landscape/asset06.ext
> /tmp/client02/images/landscape/file03.ext
> /tmp/client02/images/landscape/file04.ext
> /tmp/client02/images/landscape/file06.ext
> /tmp/client02/images/landscape/thumbnails/thumbnail03.ext
> /tmp/client02/images/landscape/thumbnails/thumbnail04.ext
> /tmp/client02/images/landscape/thumbnails/thumbnail06.ext
> /tmp/client03/images/landscape/asset03.ext
> /tmp/client03/images/landscape/asset04.ext
> /tmp/client03/images/landscape/asset06.ext
> /tmp/client03/images/landscape/file03.ext
> /tmp/client03/images/landscape/file04.ext
> /tmp/client03/images/landscape/file06.ext
> /tmp/client03/images/landscape/thumbnails/thumbnail03.ext
> /tmp/client03/images/landscape/thumbnails/thumbnail04.ext
> /tmp/client03/images/landscape/thumbnails/thumbnail06.ext
> /tmp/client04/images/landscape/asset03.ext
> /tmp/client04/images/landscape/asset04.ext
> /tmp/client04/images/landscape/asset06.ext
> /tmp/client04/images/landscape/file03.ext
> /tmp/client04/images/landscape/file04.ext
> /tmp/client04/images/landscape/file06.ext
> /tmp/client04/images/landscape/thumbnails/thumbnail03.ext
> /tmp/client04/images/landscape/thumbnails/thumbnail04.ext
> /tmp/client04/images/landscape/thumbnails/thumbnail06.ext
> /tmp/client05/images/landscape/asset03.ext
> /tmp/client05/images/landscape/asset04.ext
> /tmp/client05/images/landscape/asset06.ext
> /tmp/client05/images/landscape/file03.ext
> /tmp/client05/images/landscape/file04.ext
> /tmp/client05/images/landscape/file06.ext
> /tmp/client05/images/landscape/thumbnails/thumbnail03.ext
> /tmp/client05/images/landscape/thumbnails/thumbnail04.ext
> /tmp/client05/images/landscape/thumbnails/thumbnail06.ext
> /tmp/client06/images/landscape/asset03.ext
> /tmp/client06/images/landscape/asset04.ext
> /tmp/client06/images/landscape/asset06.ext
> /tmp/client06/images/landscape/file03.ext
> /tmp/client06/images/landscape/file04.ext
> /tmp/client06/images/landscape/file06.ext
> /tmp/client06/images/landscape/thumbnails/thumbnail03.ext
> /tmp/client06/images/landscape/thumbnails/thumbnail04.ext
> /tmp/client06/images/landscape/thumbnails/thumbnail06.ext
> /tmp/client07/images/landscape/asset03.ext
> /tmp/client07/images/landscape/asset04.ext
> /tmp/client07/images/landscape/asset06.ext
> /tmp/client07/images/landscape/file03.ext
> /tmp/client07/images/landscape/file04.ext
> /tmp/client07/images/landscape/file06.ext
> /tmp/client07/images/landscape/thumbnails/thumbnail03.ext
> /tmp/client07/images/landscape/thumbnails/thumbnail04.ext
> /tmp/client07/images/landscape/thumbnails/thumbnail06.ext
> /tmp/client08/images/landscape/asset03.ext
> /tmp/client08/images/landscape/asset04.ext
> /tmp/client08/images/landscape/asset06.ext
> /tmp/client08/images/landscape/file03.ext
> /tmp/client08/images/landscape/file04.ext
> /tmp/client08/images/landscape/file06.ext
> /tmp/client08/images/landscape/thumbnails/thumbnail03.ext
> /tmp/client08/images/landscape/thumbnails/thumbnail04.ext
> /tmp/client08/images/landscape/thumbnails/thumbnail06.ext
> /tmp/client09/images/landscape/asset03.ext
> /tmp/client09/images/landscape/asset04.ext
> /tmp/client09/images/landscape/asset06.ext
> /tmp/client09/images/landscape/file03.ext
> /tmp/client09/images/landscape/file04.ext
> /tmp/client09/images/landscape/file06.ext
> /tmp/client09/images/landscape/thumbnails/thumbnail03.ext
> /tmp/client09/images/landscape/thumbnails/thumbnail04.ext
> /tmp/client09/images/landscape/thumbnails/thumbnail06.ext
> /tmp/client10/images/landscape/asset03.ext
> /tmp/client10/images/landscape/asset04.ext
> /tmp/client10/images/landscape/asset06.ext
> /tmp/client10/images/landscape/file03.ext
> /tmp/client10/images/landscape/file04.ext
> /tmp/client10/images/landscape/file06.ext
> /tmp/client10/images/landscape/thumbnails/thumbnail03.ext
> /tmp/client10/images/landscape/thumbnails/thumbnail04.ext
> /tmp/client10/images/landscape/thumbnails/thumbnail06.ext
>
> On Thu, Mar 11, 2010 at 1:22 PM, Lightner, Jeff <jlightner at water.com> wrote:
>> Part of the issue may be the asynchronous way replies hit the list.
>>
>> By the time one's post hits the list its contents may have been obviated
>> by other posts that weren't there at the time it was submitted.  The OP
>> wasn't clear in whether he was looking for differences between multiple
>> clients or just within the subdirectories of each client so some of the
>> posts addressed what they thought he was asking.
>>
>> The OP clarified what he was asking and what I wrote would do what he
>> asked  based on my testing.  I haven't tested the other solutions so they
>> may be better or worse than mine.
>>
>> -----Original Message-----
>> From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of
>> Richard Bronosky
>> Sent: Thursday, March 11, 2010 12:44 PM
>> To: Atlanta Linux Enthusiasts - Yes! We run Linux!
>> Subject: Re: [ale] Stumped-
>>
>> The multiple clients thing is extraneous info and I wish we could all
>> forget it. It's like describing what you had for breakfast in the
>> middle of your task explanation. They would eat you up for this line
>> of questioning on irc://irc.freenode.net/#bash (which is a GREAT
>> resource!) I think this explains it pretty well:
>> [12:39pm] RichardBronosky: !b1
>> [12:39pm] greybot: bashphorism 1: the questioner's first description
>> of the problem/question will be misleading.
>>
>> On Thu, Mar 11, 2010 at 12:32 PM, Geoffrey <lists at serioustechnology.com>
>> wrote:
>>> Dennis Ruzeski wrote:
>>>> Just to be clear--
>>>>
>>>> Per client, I need to find files with the same name but different sizes.
>>>
>>> Oops, so you're not comparing client to client?  My script I sent
>>> earlier will still work, you just need to run it from the clients
>>> directory.
>>>
>>>>
>>>>
>>>> On Thu, Mar 11, 2010 at 10:32 AM, Dave Weiner
>>>> <davew at coyotetechnical.com> wrote:
>>>>> Dennis Ruzeski wrote:
>>>>>> Same name but different size.
>>>>> I got that part, but are you comparing files limited to just the
>>>>> client,
>>>>> or do you have to compare it against the other 9,999 clients?
>>>>>
>>>>> If it's contained to just the one client, you can't have two files with
>>>>> the same name in the same directory with different sizes.
>>>>>
>>>>> You need to better explain what you are trying to do.
>>>>>
>>>>> Dave
>>>>> _______________________________________________
>>>>> Ale mailing list
>>>>> Ale at ale.org
>>>>> http://mail.ale.org/mailman/listinfo/ale
>>>>> See JOBS, ANNOUNCE and SCHOOLS lists at
>>>>> http://mail.ale.org/mailman/listinfo
>>>>>
>>>> _______________________________________________
>>>> Ale mailing list
>>>> Ale at ale.org
>>>> http://mail.ale.org/mailman/listinfo/ale
>>>> See JOBS, ANNOUNCE and SCHOOLS lists at
>>>> http://mail.ale.org/mailman/listinfo
>>>>
>>>
>>>
>>> --
>>> Until later, Geoffrey
>>>
>>> "I predict future happiness for America if they can prevent
>>> the government from wasting the labors of the people under
>>> the pretense of taking care of them."
>>> - Thomas Jefferson
>>> _______________________________________________
>>> Ale mailing list
>>> Ale at ale.org
>>> http://mail.ale.org/mailman/listinfo/ale
>>> See JOBS, ANNOUNCE and SCHOOLS lists at
>>> http://mail.ale.org/mailman/listinfo
>>>
>>
>>
>>
>> --
>> .!# RichardBronosky #!.
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>>
>> Proud partner. Susan G. Komen for the Cure.
>>
>> Please consider our environment before printing this e-mail or
>> attachments.
>> ----------------------------------
>> CONFIDENTIALITY NOTICE: This e-mail may contain privileged or confidential
>> information and is for the sole use of the intended recipient(s). If you are
>> not the intended recipient, any disclosure, copying, distribution, or use of
>> the contents of this information is prohibited and may be unlawful. If you
>> have received this electronic transmission in error, please reply
>> immediately to the sender that you have received the message in error, and
>> delete it. Thank you.
>> ----------------------------------
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>>
>
>
>
> --
> .!# RichardBronosky #!.
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
>



More information about the Ale mailing list