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: Bernd Eggink
Subject: Re: implementing flow control in bash
Date: Tue, 21 Oct 2008 23:30:40 +0200
User-agent: Thunderbird 2.0.0.17 (X11/20080914)

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]