1753812 Members
8104 Online
108805 Solutions
New Discussion юеВ

grep -w

 
SOLVED
Go to solution
andi_1
Frequent Advisor

grep -w

Hi guys,

I am using 11.i and I used the following option in grep command -w to grep for a specific word. (grep -w)

I just found out that -w option doesn't exist on 11.0.
I don't have 11.0 - does anyone know what is 11.0 equvalent of grep -w?

Thanks a lot!
10 REPLIES 10
harry d brown jr
Honored Contributor

Re: grep -w

gnu grep:

http://hpux.cs.utah.edu/hppd/hpux/Gnu/grep-2.5a/


live free or die
harry
Live Free or Die
steven Burgess_2
Honored Contributor

Re: grep -w

Hi

on a 10.20 box

:/home/H092AHE:Sleeves:>grep -w steve /etc/passwd
grep: illegal option -- w

Have checked man pages for grep -w ( nothing found)

Anyone else ?

Steve
take your time and think things through
andi_1
Frequent Advisor

Re: grep -w

Unfortunately, my code will be running on customer's systems, and I cannot rely that they have gnu grep.

James R. Ferguson
Acclaimed Contributor

Re: grep -w

Hi:

You can circumvent this by enclosing your string in quotes and providing whitespace, for instance:

# grep -e "^abc" -e " def " -e "abc$"

Regards!

...JRF...
Pete Randall
Outstanding Contributor

Re: grep -w

Nope, no -w in 10.20 or 11.0.
It's apparently a new feature of 11i. I don't think there is an equivalent option in HP-UX grep.

Pete

Pete
James R. Ferguson
Acclaimed Contributor
Solution

Re: grep -w

Hi (again):

Sorry, the example should have been:

# grep -e "^abc" -e " abc " -e "abc$" filename

Regards!

...JRF...
Jeffrey Davis_1
Frequent Advisor

Re: grep -w

Hi all. I've got to say - Ugh!
I've been working on a script the past two days to help me pull the encrypted passwd entry from the respective system accounts in the /tcb/files/auth/* (trusted system dbase area)and pad those entries into field 2 of a temp/psuedo file that resembles the /etc/passwd file. (Basically, recreating the original /etc/passwd file from before the system was trusted.) I can then run this script on any system, extract and pad the necessary encrypted info, then take that output file and run it through the Crack5.0 engine.
Well, to make a long story short. I've been stuck on one particular area of the script. Everything about it worked fine except for one small thing. How to adapt for a search for a user who pulled up multiple matches. i.e. "uucp" would find "uucp and nuucp".
I knew the answer was with using regular expressions, but couldn't find the exact fit. And then I came accross this post today about "grep -w". In fact, I tried playing around with that earlier today, but made no headway. Basically, my problem was I was using the "/" from grep's metacharacter regular expressions. I took these out and it worked fine.

Thanks for the post.

Like I said - To make a short story long!
Just because it is a nice clean way to parse and pad this info I will attatch the script in the event someone wants to use it as they work with Crack. Or if someone can add it to the script archives.
Tom Danzig
Honored Contributor

Re: grep -w

I got this off the forums a while back. I'd give credit to who wrote it, however, it's not in the script nor do I remember ...
Tom Danzig
Honored Contributor

Re: grep -w

One more time .. this time with the attachment.
============================
I got this off the forums a while back. I'd give credit to who wrote it, however, it's not in the script nor do I remember ...