Re: implementing flow control in bash
Works perfectly, thanks! I'll study up on the syntax... Tony On Tue, Oct 21, 2008 at 5:30 PM, Bernd Eggink [EMAIL PROTECTED] 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
implementing flow control in bash
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
Re: implementing flow control in bash
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