Computing.Net > Forums > Unix > grep problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

grep problem

Reply to Message Icon

Name: Jim
Date: December 1, 2002 at 12:00:56 Pacific
OS: FreeBSD
CPU/Ram: 512
Comment:

Hello,

I'm trying to grep all people named John from an employee file in Bourne Shell. The problem is that some of the street names also have John in them. For example here are a couple lines of data:

Sales John Jacobs 32 Oriole Lane
IT Rich Gardener 443 John Street

Any help would be GREATLY appreciated, thank you.



Sponsored Link
Ads by Google

Response Number 1
Name: Leigh
Date: December 1, 2002 at 13:57:23 Pacific
Reply:

Jim,
Here, give this command a go........

awk '{print $2}' test.dat | grep John

It will get the given name field from the file and the grep will only look for John.

Cheers
Leigh


0

Response Number 2
Name: Jim
Date: December 1, 2002 at 19:54:15 Pacific
Reply:

I'm sorry,

I forgot to say that I actually have to print just the name and address where a person named JOhn is found. That is my problem. Thank you so much.


0

Response Number 3
Name: Jimbo
Date: December 2, 2002 at 05:19:34 Pacific
Reply:

awk '$2 ~ /John/{print $2, $3, $4, $5, $6}' your_file


-jim


0

Response Number 4
Name: Jim
Date: December 2, 2002 at 12:48:05 Pacific
Reply:

Thank you very much!



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: grep problem

Grep problems www.computing.net/answers/unix/grep-problems/5776.html

Help with this grep problem www.computing.net/answers/unix/help-with-this-grep-problem/6884.html

Loop to grep for key word in log www.computing.net/answers/unix/loop-to-grep-for-key-word-in-log/5008.html