All, I have a string from which I want to extract a substring. The thing is that the starting position is stored in variable. AWK Doesn't seem to recognize the variable.
Here is the code
str="This is a test"
s1="is"
i=$(awk -v a="$str" -v b="$s1" 'BEGIN{print index(a,b)}')
echo "$str" | awk '{print substr($0,$i)}'
But this doesn't work. How do coerce awk to recognize i
?