Q:

Strange shell behaviour

Here is a simple bash script:
a="asd"
b="qf"
echo "$a.$b"
echo "$a_$b"

It's output is:
asd.qf
qf

Why the second line is not "asd_qf" but "qf"?

A:

Because you haven't defined a variable named a_. For that second printout to work, use:
echo "${a}_$b"

A:

Your second echo displays the value of variable $a_ which is unset.
Use echo "${a}_$b"

A:

The shell has rules about what can go in a variable name, and $a_ is interpreted as the variable named a_ (there is no variable with that name so its value is empty).
You can always add braces to be explicit.  In this case, ${a}_$b will clearly identify what the variable name is and the result will be what you expect.

