[magick-users] loop to make 300 images
Alex Schuster
wonko at wonkology.org
Tue Jun 3 19:31:48 PDT 2008
Fred Weinhaus writes:
> Note that the following looping constructs do not work on the Mac.
>
> for i in `seq 1 300`; do
> ...
> done
>
> There is no seq command on the Mac OS
I wonder why they die not include that. If one wants it anyway, it is part
of the GNU coreutils, which can be downloaded from
<http://www.gnu.org/software/coreutils/>. After compiling, the sed binary
can be copied to somewhere in the $PATH.
> for i in {1..300}; do
> ...
> done
This works for bash >= 3.2. "bash --version" or "echo $BASH_VERSION"
prints the version.
> The only ones that i have found that work on Mac OS are
>
> i=1
> while [ $i -le 300 ]; do
> ...
> i=`expr $i + 1`
> done
bash can understand arithmetic statements in (( )) brackets, so [ $i -le
300 ] can also be written as (( i < 300 )). And i=`expr $1 + 1` can be
i=$(( i + 1 )) or simply (( i++ )).
The thread looks a little off-topic, but on the other hand a powerful tool
like imagemagic can be made even more powerful with a little knowledge of
shell scripting. In case someone got interested, I suggest the Advanced
Bash Scripting Guide at <http://tldp.org/LDP/abs/html/>.
Wonko
More information about the Magick-users
mailing list