I have a situation where I need to use the bash variable in awk, but it is not working.
file.txt
Fruit Good
try.sh
var="apple"
awk '{print $var " " $1 " " $2}' file.txt
Expected Output:
apple Fruit Good
Code Output:
Fruit Good Fruit Good
It seems the content of file.txt
is get replaced by variable $var
. Please suggest me correct approach.