I have data like the following:
apple pear sugar pizza
pizza chicken pasta turkey
I want to grep for "pizza" but only grep the fourth column. I know i can use:
awk '$4 == "pizza"'
However i have a variable named food which contains the word pizza. When i do
food=pizza
awk '$4 == "$food"'
I receive an error and also when i change to double apostrophes i receive this error:
awk: line 1: syntax error at or near ==
how can i achieve this?