I am trying to pass two variables to awk in order to replace a word (-v var1) with a space (” “) at specific line (-v var2). When I ran it, nothing is replaced at the line I wanted.
My first approach to do it is:
palabra=betina; i=5 ; awk -v var1="$i" -v var2="$palabra" 'NR==var1 {sub("var2"," ")}{print }' Countries > tmp
on the file “Countries”, with content is:
usa
usa
colombia
spain
betina
Remove the quotes around
var2and you should be good.