The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep command christine33990 UNIX for Dummies Questions & Answers 11 05-05-2008 11:45 PM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-04-2007 11:59 PM
grep command help ishmael^soyuz Shell Programming and Scripting 4 07-11-2007 06:01 AM
grep command pmsuper UNIX for Dummies Questions & Answers 6 11-22-2006 03:12 AM
grep command debasis.mishra Shell Programming and Scripting 1 03-27-2006 10:53 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-12-2004
Registered User
 

Join Date: Nov 2003
Location: Grimsby
Posts: 17
Stumble this Post!
grep command

Hi

i am trying to grep a specific word out of a file but it is bring up every instance of the word even if it is part of another word.

For example i am trying to grep the word ist, now there should be only one instance of this in the file i am grepping but it is bring up a whole list as it is finding it as part of other words.

I have tried the -E, -F, -x parameters infront of grep but nothing seems to work. Can anybody help please.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-12-2004
malcom's Avatar
Registered User
 

Join Date: Jul 2003
Location: Germany
Posts: 78
Stumble this Post!
Hi,

if your are grepping for the word 'ist', I think the word will be leaded by a space, right ? So try following ..

# ... grep " ist"

OR

# ... grep " ist "

This is the way how I usually do it, it's fast and it's working ...

Regards
Malcom
Reply With Quote
  #3 (permalink)  
Old 10-13-2004
Registered User
 

Join Date: Jan 2002
Location: Arlington, TX
Posts: 4
Stumble this Post!
try grep -w ist
Reply With Quote
  #4 (permalink)  
Old 10-14-2004
Registered User
 

Join Date: Nov 2003
Location: Grimsby
Posts: 17
Stumble this Post!
The problem has now been solved thank you for your help.
Reply With Quote
  #5 (permalink)  
Old 10-16-2004
moxxx68's Avatar
Registered User
 

Join Date: Mar 2004
Posts: 301
Stumble this Post!
simple suggestion ...

if you are trying to grep an instnace of a word that is a whole word by itself but may be in combination with other words try this too...
grep '\<word\>' Filename
and that should give you the exact word you're looking for every time without interfering with other whole words..
syntax..... '\<word\>'
moxxx68
__________________
moxxx68
http://www.estarinformado.com.ar/apicmaxmiel/bee-diez.gif
Reply With Quote
  #6 (permalink)  
Old 02-08-2007
Registered User
 

Join Date: Nov 2006
Posts: 39
Stumble this Post!
So what was the solution to the problem. I have a similar issue and the version of grep doesn't support the -x option and it appears to ignore the -w option as well.
Reply With Quote
  #7 (permalink)  
Old 03-05-2007
Registered User
 

Join Date: Feb 2007
Location: Boston, MA
Posts: 64
Stumble this Post!
Quote:
Originally Posted by lazytech
So what was the solution to the problem. I have a similar issue and the version of grep doesn't support the -x option and it appears to ignore the -w option as well.
Try to use "fgrep". That would have the "-x" option.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0