Why using variable in awk printf doesn't work? Newbie here. I am trying to use awk print a few information. So I wrote a shell scripts
#!/bin/bash

turbVar="U"
bcName="outlet"
str="$turbVar $bcName b.c. = "
# method-1
awk -v RS='}' '/'$bcName'/ { printf "%20s = %s\n" $str $4; exit;}' BCFile  | tr -d ";"
# method-2
awk -v RS='}' -v var1=$bcName '$0 ~ var1 { printf "%20s = %s\n" $str $4; exit;}' BCFile  | tr -d ";"

The BCFile file contents are
boundary
{
    inlet
    {
typefixedValue;
valueuniform (5 0 0);
    }

    outlet
    {
typeinletOutlet;
inletValue      $internalField;
value$internalField;
    }

    ....
} 

I hope to output something like
U outlet b.c. = inletOutlet

Sadly, this does not work. it complains awk: (FILENAME=0/U FNR=4) fatal: not enough arguments to satisfy format string %20s = %s.
Why I can't use $str variable in awk printf?
Second question, which method is better? Using '/'$bcName'/ or using -v var1=$bcName '$0 ~ var1?, why I cant use '/$bcName/ or '/"$bcName"/directly? What is the difference between strong quote and weak quote here?

You code cleaned up should be:
awk -v RS="}" -v v1="$bcName" -v s="$str" '$0~v1{gsub(/;/,"");printf "%s%s\n",s,$4;exit}' 
U outlet b.c. = inletOutlet

Notes: 


*

*Don't play with shell expansion and quoting it's a real headache. Pass in any shell variables nicely with -v.

*You need to comma separator the arguments to printf. 

*Always quote your shell variables! 

*You should being doing gsub(/;/,"") inside the awk script instead of tr -d ";".
However it may not be the best approach but I couldn't say as no context was provied.