Skip to main content
1 of 2

@Chris Page offered a perfectly acceptable answer, because it addresses all of your necessary issues, but then I took a second look at your code and wondered why not use a function with a loop instead of all those variable commands?

ink() {
  square_dimension="$2"
  infile="$1"
  /Applications/Inkscape.app/Contents/Resources/bin/inkscape --export-png "${root}/test_${square_dimension}.png" -w ${square_dimension} -h ${square_dimension} "$infile"
}

for i in {256,128,64,48,40,32,24,16}; do ink "$1" "$i"; done

Note that the above code has not been tested. I will update after I have had a chance to test it, but it looks good to me. You may need to export the function or something (export -f ink) or mess around with the argument variables -- but like I said, I will post an update after I've had a chance to test it, but like I said before, @Chris Page offered an answer that pretty much answers your question. This is simply additional info that is better formatted as a question rather than multiple comments.

Also, it's best practices to always use lowercase variable names in shell scripts so as not to overwrite any of the built-in environment variables (which is something that I have struggled with, because the variables are so much easier to recognize -- especially in a large script on a system without a colored terminal for syntax highlighting).