bash - why variable losing its value within the loop -
i trying use loop variable within loop. seems loosing value after using 1 time(may misunderstanding). here code
for in {2000..2014} echo “training representation$i_by_$i , testing representation$1999_by_$i” done i want output should this-
training representation2000_by_2000 , testing representation1999_by_2000
but actual output this-
training representation2000 , testing representation1999_by_?? can body help?
because you're using curly quotes around string. character ” not special character shell, it's being treated part of variable name. there's no variable named i”.
change ascii double quotes around string. also, since _ can in variable name, need use ${i} when variable followed character (or other character can in variable name); otherwise, it's looking variable named $i_by_.
finally, $1999 being interpreted $1 (the first argument script)followed by999. prevent that, need escape the$`.
for in {2000..2014} echo "training representation${i}_by_$i , testing representation\$1999_by_$i" done and stop using word processor edit programs. use programming editor, won't auto-correct quoting.
Comments
Post a Comment