1820243 Members
2550 Online
109621 Solutions
New Discussion юеВ

grep -w

 
Jasmin Berube
Advisor

grep -w

How do I grep for a whole word if I don't have the -w option available like on 10.20 and 11.00?? When I grep bob in a file I don't want to catch bobo as an example.
9 REPLIES 9
John Poff
Honored Contributor

Re: grep -w

Hi,

What flavor and version of O/S are you referring to? My HP-UX 11.11 grep has the -w switch in it.

JP
Jasmin Berube
Advisor

Re: grep -w

I just want to be able to grep a word on all platform not just 11i
Sandip Ghosh
Honored Contributor

Re: grep -w

Try to give like grep "bob"

Sandip
Good Luck!!!
Martin Johnson
Honored Contributor

Re: grep -w

Try grep "bob ".

(Space after bob - in case it doesn't post properly.)

HTH
Marty
Jasmin Berube
Advisor

Re: grep -w

It's a good idea with the space "bob " but it's doesn't work.
Bill Hassell
Honored Contributor

Re: grep -w

The man page tells all...no -w for 10.20 or 11.0 (and very little likelihood that the 11i version will be backported to 11.0, no possibility for the almost obsolete 10.20 systems). You'll have to use the trailing (and perhaps leading) space method to find a specific word rather than a portion of any string.


Bill Hassell, sysadmin
Oleg Zieaev_1
Regular Advisor

Re: grep -w

Hello.

Putting your word in the "" will do the trick.

Hope this helps,
0leg
Professionals will prevail ...
Patrick Wallek
Honored Contributor

Re: grep -w

And if you want to grep for a whole word regardless of case: grep -i " someword "

Note the spaces before and after the word.
Jasmin Berube
Advisor

Re: grep -w

Thanks to every one, finally the solution was my word with a TAB at the end, like this "bobTAB" it's hard to show it but I guess you understand.