Hi,
I am scanning certain tables in a comma-delimited file for some number (shell variable $1) in the 3 field of each record and then getting the index number of that record (field $1) when it finds a match.
nawk '/table1/, /table2/' tempfile | nawk -v X=$1 'BEGIN {FS=","} $3 ~ X {print $1}
The problem I am running into is I want to only retrieve the records for X and not when X is part of some other number. (If x is 10, it returns true for 10, 100, 110 etc).
I've tried regular expressions but I can't seem to find the correct syntax.
nawk '/start/, /stop/' tempfile | nawk -v X=$1 'BEGIN {FS=","} $3 ~ /^X$/{print $1}
Any help would be appreciated.
Thanks.
I am scanning certain tables in a comma-delimited file for some number (shell variable $1) in the 3 field of each record and then getting the index number of that record (field $1) when it finds a match.
nawk '/table1/, /table2/' tempfile | nawk -v X=$1 'BEGIN {FS=","} $3 ~ X {print $1}
The problem I am running into is I want to only retrieve the records for X and not when X is part of some other number. (If x is 10, it returns true for 10, 100, 110 etc).
I've tried regular expressions but I can't seem to find the correct syntax.
nawk '/start/, /stop/' tempfile | nawk -v X=$1 'BEGIN {FS=","} $3 ~ /^X$/{print $1}
Any help would be appreciated.
Thanks.