[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
implementing flow control in bash
From: |
Tony Zanella |
Subject: |
implementing flow control in bash |
Date: |
Tue, 21 Oct 2008 14:03:56 -0400 |
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
Any suggestions?
Tony
- implementing flow control in bash,
Tony Zanella <=