$ ASDF=hello; a=0; a=$(( 70 - $(echo $ASDF | awk '{print length}') )); echo "$a $ASDF"$(for i in {1..$a}; do printf "."; done) 65 hello. $
Why doesn't it print: 65 hello.................................................................
What am i missing?
On 1/2/11 4:27 PM, S Mathias wrote:
$ ASDF=hello; a=0; a=$(( 70 - $(echo $ASDF | awk '{print length}') )); echo "$a $ASDF"$(for i in {1..$a}; do printf "."; done) 65 hello. $
Why doesn't it print: 65 hello.................................................................
What am i missing?
Order of operations. Brace expansion happens before variable substitution (echo $i to see the actual value you are getting).
On Sun, Jan 2, 2011 at 2:27 PM, S Mathias smathias1972@yahoo.com wrote:
$ ASDF=hello; a=0; a=$(( 70 - $(echo $ASDF | awk '{print length}') )); echo "$a $ASDF"$(for i in {1..$a}; do printf "."; done) 65 hello. $
Why doesn't it print: 65 hello.................................................................
What am i missing?
This is not a group for basic shell programming questions, nor is the Ubuntu list where you also posted this exact same question.
Please learn to do your own homework and ask list-appropriate questions in the right lists.
I'm guessing that a little basic netiquette is what you are missing.
From: S Mathias smathias1972@yahoo.com
$ ASDF=hello; a=0; a=$(( 70 - $(echo $ASDF | awk '{print length}') )); echo "$a $ASDF"$(for i in {1..$a}; do printf "."; done) 65 hello. Why doesn't it print: 65 hello................................................................. What am i missing?
$ for i in {1..3}; do echo $i; done 1 2 3 $ a=3; for i in {1..$a}; do echo $i; done {1..3}
Try with: for ((i=1;i<=$a;i++))
JD