bash - Expand a variable inside `` command -
i not find exact reference i'm doing...
i have following script not expand variable inside command:
#!/bin/bash name="my name" `convert -pointsize 250 -font /usr/share/fonts/truetype/msttcorefonts/impact.ttf -fill black -draw 'text 330,900 "$name"' tag.jpg name_my.jpg`
this results in image has text $name instead of content of name.
i need read lines file , rund command on each name real script is(has same problem):
arr=(`cat names.txt`) (( i=0; i<${len}; i+=2 )); `convert -pointsize 250 -font /usr/share/fonts/truetype/msttcorefonts/impact.ttf -fill black -draw 'text 330,900 "$(${arr[i]} ${arr[i+1]})"' tag.jpg name_${arr[i]}.jpg` done
you have escaping problem. either use proper escaping backslash, or make sure otherewise $args not "protected" single quotes. e.g.
name="bla" # using escape character \ value1="foo \"${name}\"" # putting single-quotes inside double-quotes value2="foo '"${name}"'"
to better see going on, try break down problem multiple smaller problems. e.g. create "draw" command expansions before using in convert
name="my name" draw="text 330, 900 '"${name}"'" convert -pointsize 250 -fill black -draw "${draw}" tag.jpg name_my.jpg
Comments
Post a Comment