Code Comments
Programming Forum and web based access to our favorite programming groups.What am I missing here? File: http://standards.ieee.org/regauth/oui/oui.txt Need: to reveal the company name, based on the first 3 bytes of the MAC address ($3 of every line where $1 is in xx-xx-xx format, with x=[0-9a-f] awk script attempted: awk '$1 ~ /^[0-9a-f][0-9a-f]-[0-9a-f][0-9a-f]-[0-9a-f][0-9a-f]/i {print $3}' oui.txt Instead I am getting $3 of EVERY line, not only those matching pattern ... What am I missing?!? TIA, papi
Post Follow-up to this messagepapi wrote: > What am I missing here? > > File: > http://standards.ieee.org/regauth/oui/oui.txt > > Need: to reveal the company name, based on the first 3 bytes of the MAC > address ($3 of every line where $1 is in xx-xx-xx format, with x=[0-9a-f] > > awk script attempted: > > awk '$1 ~ /^[0-9a-f][0-9a-f]-[0-9a-f][0-9a-f]-[0-9a-f][0-9a-f]/i {print > $3}' oui.txt > > Instead I am getting $3 of EVERY line, not only those matching pattern ... > > What am I missing?!? You are missing the fact that - must be escaped. This one works (tested): awk '$1 ~ /^[0-9a-f][0-9a-f]\-[0-9a-f][0-9a-f]\-[0-9a-f][0-9a-f]/ {print $3} ' oui.txt
Post Follow-up to this messageIn article <30earoF2urcspU1@uni-berlin.de>,
examnotes <Juergen.KahrsDELETETHIS@vr-web.de> wrote:
...
>
>You are missing the fact that - must be escaped.
>This one works (tested):
>
>awk '$1 ~ /^[0-9a-f][0-9a-f]\-[0-9a-f][0-9a-f]\-[0-9a-f][0-9a-f]/ {print $3}' oui.t
xt
I don't think that is true. The "-" is not inside of [], so it is just an
ordinary character.
I think the problem has to do with the "i" at the end of the original reg
exp. I recognize that as TAWK syntax for doing a case-insensitive match.
It looks like the OP was trying to use it on a non-TAWK version.
Post Follow-up to this messageOn Mon, 22 Nov 2004 15:19:36 +0100, Jürgen Kahrs wrote:
> papi wrote:
>
> You are missing the fact that - must be escaped.
> This one works (tested):
>
> awk '$1 ~ /^[0-9a-f][0-9a-f]\-[0-9a-f][0-9a-f]\-[0-9a-f][0-9a-f]/ {print $3}' oui.
txt
Thank you - I thought I have tried this before, but you know what I
screwed me up that time? The /i at the end! Once I looked at yours I
realized the screw-up ... thx!
Post Follow-up to this messageKenny McCormack wrote: > I think the problem has to do with the "i" at the end of the original reg > exp. I recognize that as TAWK syntax for doing a case-insensitive match. > It looks like the OP was trying to use it on a non-TAWK version. I thought the i was a typo.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.