title: Variables in awk inside a for loop
body: <p>I have a problem in my bash script.</p>
  <pre><code>for b in O B A F G K M
  do   
  u='$n'$b  
  w='$m'$b  
  awk -v &quot;j=$u&quot; -v &quot;h=$b&quot; 'BEGIN{printf(&quot; &quot;h&quot; stars: %6d  &quot;, j)}'  
  awk -v &quot;i=$w&quot; 'BEGIN{printf(&quot;%&quot;i&quot;s\n&quot;, &quot;[]&quot;)}' | sed 's/ /[]/g'  
  done
  </code></pre>
  <p>I need to use variables called &quot;nO&quot; then &quot;nB&quot; etc in awk. My teacher suggested assigning values of these to another variables before awk, but when I do this it just prints &quot;$nO&quot; instead of its value like &quot;200&quot;. How to do this? I need something like: awk -v j=$[n$b], so j is assigned the value of variable nO in first loop, then the value of nB. (These nO or mO are already defined earlier.</p>