I want to match string stored in a shell variable. So far I have working code
awk '/xyz/{ print "xyz found"} input
What I need is:
str="xyz"
awk '/$str/{ print "xyz found"} input
But it doesn’t work so I searched and found solution:
str="xyz"
awk -v search="$str" '/search/{ print "xyz found"} input
It won’t work either. So how can I match a pattern given in a variable in awk passed from shell?