awk 's construct /var/ looks for exactly that: the three char sequence "v", "a", and "r". That is not recognised as a variable and thus not replaced by its value.
Try $0 ~ var or the match function.
EDIT: Not exactly sure what you're after, but would this go into the right direction:
awk '
1
/\(\)/ {sub (/\(\)/, _)
var = $0
L = NR + 1
}
NR == L {print "echo \"" var "\""
}
' scriptname
As my script is having too many functions.I need to know the flow while executing..Because of that i need to print each function names inside the function(echo 'functionname')
Note:I can check the flow using bash -x. But it will be better if i know the flow with normal execution.