bash - awk print variable with spaces -
how pass variable containing space awk 1 variable?
code:
a="one" b="two three" c="four" echo $a $b $c | awk '{ print "a="$1 "\nb="$2 "\nc="$3 }'
expected output:
a=one b=two 3 c=four
actual output:
a=one b=two c=three
you use awk
's -v
option pass shell parameters awk
:
a="one" b="two three" c="four" echo | awk -va="$a" -vb="$b" -vc="$c" '{ print "a="a "\nb="b "\nc="c }'
Comments
Post a Comment