【发布时间】:2016-04-26 11:39:48
【问题描述】:
我想执行一个复杂的 bash 命令,使用从长数组提供的数据作为参数。我想它必须以某种方式使用子shell。
例如,代替可行的
convert -size 100x100 xc:black -fill white -draw "point 1,1" -draw "point 4,8" -draw "point 87,34" etc etc etc image.png
我想采用不同的逻辑,其中参数在同一命令中给出,更像
convert -size 100x100 xc:black -fill white $(for i in 1,1 4,8 87,34 etc etc; -draw "point $i"; done) image.png
这不起作用,因为 $i 被解释为包含参数的命令。
请注意,“for i in ...; do convert ...$i...; done”将不起作用。 -draw "point x,y" 系列参数必须在同一个运行 convert 命令中,因为 convert 不接受现有图像中的 -draw 参数。
【问题讨论】:
-
您需要
echo/printf来自嵌入式-draw ...循环的-draw ...字符串。
标签: bash for-loop parameter-passing imagemagick-convert