Using grep with hyphens

This is on a RHEL 6 box with bash 4.1.2

I'm trying to to use grep to only find those lines containing matches that form whole words.

The -w option works fantastic unless of course that word has a hyphen.

The problem is I will get a hit on "test-group" which is a good thing, but I will also get a hist on "test" which is bad because the group test doesn't exist. It appears that once grep hits a hyphen it treats the preceding text as a whole word.

Any ideas would be greatly appreciated.

Next time no groups with hyphens..

Thanks
 
woodson2 said:
This is on a RHEL 6 box with bash 4.1.2

This seems to be an odd place to be asking about that, then...

I'm trying to to use grep to only find those lines containing matches that form whole words.

The -w option works fantastic unless of course that word has a hyphen.

The problem is I will get a hit on "test-group" which is a good thing, but I will also get a hist on "test" which is bad because the group test doesn't exist. It appears that once grep hits a hyphen it treats the preceding text as a whole word.

# grep -w test -- myfile
 
Back
Top