bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: implementing flow control in bash


From: Tony Zanella
Subject: Re: implementing flow control in bash
Date: Wed, 22 Oct 2008 14:06:18 -0400

Works perfectly, thanks! I'll study up on the syntax...
Tony

On Tue, Oct 21, 2008 at 5:30 PM, Bernd Eggink <monoped@sudrala.de> wrote:
> Tony Zanella schrieb:
>>
>> Hello all,
>> I'm sure this isn't a bug, but just my inability to wrap my head
>> around enough of bash flow control:
>> I wrote the following shell script to find all gifs in a directory.
>> Then use "identify" from imagemagick to grab the gif width. Then,
>> print the image name and width to a file.
>>
>>  for i in `find . -name \*gif`; do identify -format "$i %w" $i; done
>>>
>>> results.txt
>>
>> Then, I used a ruby script to cull only those images with a width over
>> 570 pixels. So, problem solved, but I wanted to see if I could do it
>> all in bash.
>> More specifically, (if this makes sense) I want to "do identify
>> -format "$i %w" $i" only for those "$i %w" where "%w" is > 570.
>>
>> The above script will give me output like:
>>
>>  image1.gif 360
>>  image2.gif 780
>>
>> But I want it to give me:
>>
>>  image1.gif 360
>>
>> In pseudo-code, I want something like:
>>
>>  for i in `find . -name \*gif`; do identify -format "$i %w" $i if [%w
>>>
>>> 570]; done > results.txt
>
> for i in $(find -name '*.gif')
> do
>    w=$(identify -format %w $i)
>    (( w > 570 )) && echo "$i $w"
> done
>
> Hope that helps,
> Bernd
>
> --
> Bernd Eggink
> http://sudrala.de
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]