I have a following file.
cat test.txt
NE|East
OR|East
WB|East
HP|North
HR|North
JK|North
NR|North
PB|North
I have a variable circle which stores the following value.
circle="JK"
Now, I want the value matching my variable. I have used the following code, but it doesn't provide me any output. However, when I manually writes "JK", it shows me the desired result.
awk -F '|' '{if($1==$circle) print $2;}' test.txt
awk -F '|' '{if($1 == "JK") print $2;}' test.txt
North
Please suggest. Help is much appreciated.