Re: Is this a bug in grep, or is it me...
On Fri, Oct 01, 1999 at 04:19:51PM +, Dale Scheetz wrote: This leaves me with the unresolved problem of distinguishing between the two package names. I just read through the grep manpage (again) looking for something that will enforce an exact match, when I realised that I can simply skip this step and do the selection in awk (which I was using before to peel off the section name from the grep output), so the right command is: it seems to me that the word you are looking for (i.e. the package name) will always be the first word on a line, so: grep ^PACKAGENAME override.potato will do the job, and is probably significantly faster than an awk script. craig -- craig sanders
Is this a bug in grep, or is it me...
I am trying to grep the override file for the section for debhelper. I am using the whole word option (-w), but this is what I get: $ grep -w debhelper override.potato debhelper optionaldevel hello-debhelper optionaldevel In the man page, under the -w option, it says that, in order to match, the string must be either at the beginning of the line, or preceeded by a non-word contituent character, which it declares as letters, digits, and the underscore. The hyphon at the ned of hello in hello-debhelper isn't any of these, but grep declares it to match anyway! Is this something to do with the form of my expression? Any information will be greatfully appreciated, Dwarf -- _-_-_-_-_- Author of The Debian Linux User's Guide _-_-_-_-_-_- aka Dale Scheetz Phone: 1 (850) 656-9769 Flexible Software 11000 McCrackin Road e-mail: [EMAIL PROTECTED] Tallahassee, FL 32308 _-_-_-_-_-_- See www.linuxpress.com for more details _-_-_-_-_-_-_-
Re: Is this a bug in grep, or is it me...
Dale Scheetz [EMAIL PROTECTED] writes: $ grep -w debhelper override.potato debhelper optionaldevel hello-debhelper optionaldevel In the man page, under the -w option, it says that, in order to match, the string must be either at the beginning of the line, or preceeded by a non-word contituent character, which it declares as letters, digits, and the underscore. No, it says that those are word constituent characters. The hyphon at the ned of hello in hello-debhelper isn't any of these, but grep declares it to match anyway! Is this something to do with the form of my expression? It's preceded by a character that isn't a letter, digit or underscore: a hyphen.
Re: Is this a bug in grep, or is it me...
On 1 Oct 1999, Ben Pfaff wrote: Dale Scheetz [EMAIL PROTECTED] writes: $ grep -w debhelper override.potato debhelper optionaldevel hello-debhelper optionaldevel In the man page, under the -w option, it says that, in order to match, the string must be either at the beginning of the line, or preceeded by a non-word contituent character, which it declares as letters, digits, and the underscore. No, it says that those are word constituent characters. That's what I meant... The hyphon at the ned of hello in hello-debhelper isn't any of these, but grep declares it to match anyway! Is this something to do with the form of my expression? It's preceded by a character that isn't a letter, digit or underscore: a hyphen. Which confused me as to why it was being included in the word. So a search string is defined as any characters delimited by blank, tab, or newline, but because the hyphon is not considered a word constituent character, debhelper is considered a whole word within the string hello-debhelper? While this seems to be working with two definitions of what is a word (the parser considers hello-debhelper as one word while the expression analysis considers it two words), I can accept that this is the true state of affairs. This leaves me with the unresolved problem of distinguishing between the two package names. I just read through the grep manpage (again) looking for something that will enforce an exact match, when I realised that I can simply skip this step and do the selection in awk (which I was using before to peel off the section name from the grep output), so the right command is: awk -v name=debhelper ' name == $1 { print $3 } ' override.potato which produced the single line: devel rather than: grep -w debhelper override.potato |awk '{ print $3 }' which produced the two line ouput: devel devel Thanks for the education, problem-set can be a real killer. Luck, Dwarf -- _-_-_-_-_- Author of The Debian Linux User's Guide _-_-_-_-_-_- aka Dale Scheetz Phone: 1 (850) 656-9769 Flexible Software 11000 McCrackin Road e-mail: [EMAIL PROTECTED] Tallahassee, FL 32308 _-_-_-_-_-_- See www.linuxpress.com for more details _-_-_-_-_-_-_-
Re: Is this a bug in grep, or is it me...
Dale Scheetz [EMAIL PROTECTED] writes: The hyphon at the ned of hello in hello-debhelper isn't any of these, but grep declares it to match anyway! Is this something to do with the form of my expression? It's preceded by a character that isn't a letter, digit or underscore: a hyphen. Which confused me as to why it was being included in the word. So a search string is defined as any characters delimited by blank, tab, or newline, but because the hyphon is not considered a word constituent character, debhelper is considered a whole word within the string hello-debhelper? If I understand what you're saying, yes: word delimiters are not part of the words they separate. If that's not what you mean, then I guess I need a more elaborate explanation. (Sorry, I don't have enough time right now to help with your larger problem.) -- Whoever you are -- SGI, SCO, HP, or even Microsoft -- most of the smart people on the planet work somewhere else. --Eric S. Raymond