why awk returns nothing when -va=$P is set?
Code:
# cat test_innp
1 A2 23 A0 A155
2 A1 01 A6 A090
3 A3 10 A1 A015
4 A0 11 A2 A220
5 A4 33 A5 A130
6 A9 06 A3 A085
7 A5 09 AA A060
# awk '$4 ~ /^A0$/ {print $5}' test_innp
A155
# P=A0
# awk -va=$P '$4 == a {print $5}' test_innp
A155
[COLOR=red]# awk -va=$P '$4 ~ /a/ {print $5}' test_innp
# awk -va=$P '$4 ~ "/a/" {print $5}' test_innp
# awk -va=$P '$4 ~ "/$a/" {print $5}' test_innp
# awk -va=$P '$4 ~ "/$a$/" {print $5}' test_innp
# awk -va=$P '$4 ~ "/^$a$/" {print $5}' test_innp
# awk -va=$P '$4 ~ /^$a$/ {print $5}' test_innp
# awk -va=$P '$4 ~ ^a$ {print $5}' test_innp
Syntax Error The source line is 1.
The error context is
$4 ~ >>> ^ <<< a$ {print $5}
awk: 0602-500 Quitting The source line is 1.
#
[/color red]
#