In a for loop, where variable x is changing, I need to get the rows of the input.txt that have the 2nd column equals to variable x.
awk '{if ($2 == "ABC-0361-T00"){print}}' input.txt
works. However, when I define it in a variable, it does not work.
x="ABC-0361-T00"
awk '{if ($2 == $x){print}}' input.txt
awk '{if ($2 == "$x"){print}}' input.txt
What am I missing?