X=some number
cat tmpfile | awk '$13~/"$X"/{print $0}'
what i want to do is to take a user defined variable and match it to field $13 in a text file. If the match is true then print the entire line. However, I don't seem to have the syntax correct for awk to understand $X is a variable. I have tried it also as:
cat tmpfile | awk '$13~/"'$X'"/{print $0}'
cat tmpfile | awk '$13~/\$X\/{print $0}'
cat tmpfile | awk '$13~/"${X}"/{print $0}'
cat tmpfile | awk -v X=$(X) '$13~/"$X"/{print $0}'
cat tmpfile | awk '$13~/"$X"/{print $0}'
what i want to do is to take a user defined variable and match it to field $13 in a text file. If the match is true then print the entire line. However, I don't seem to have the syntax correct for awk to understand $X is a variable. I have tried it also as:
cat tmpfile | awk '$13~/"'$X'"/{print $0}'
cat tmpfile | awk '$13~/\$X\/{print $0}'
cat tmpfile | awk '$13~/"${X}"/{print $0}'
cat tmpfile | awk -v X=$(X) '$13~/"$X"/{print $0}'