LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Zgrep For Files Beginner (https://www.linuxquestions.org/questions/linux-newbie-8/zgrep-for-files-beginner-786243/)

networkingnub 02-01-2010 12:06 PM

Zgrep For Files Beginner
 
I have a number of files:

Foo
BlahhFoo

I only want to be able to grep for names in a file that contain Foo and not BlahhFoo. However I am not able to pull only those files away. How can this bee done.

My grep/zgrep knowledge only goes this far at this point. I'm still learning but I'm stuck on how to make my arguments more precise

zgrep 'Foo' SomeFileIMade.gz > /home/user/FOOFILE

Mr-Bisquit 02-01-2010 12:18 PM

I'm not that far ahead of you with grep.
Usually it's more of
Code:

locate xy |grep bin |grep session
Double grepping isn't always the best way but it does cut down on search terms.
You could also try directories such as:
Code:

locate beans | grep /usr/bin

HasC 02-01-2010 12:28 PM

Not really sure of what exactly you're wanting, but:

Code:

$ grep Foo file|grep -v BlahFoo
could do the trick. Or, another example:

Code:

$ egrep '/ Foo /' file
(notice the blank spaces)

networkingnub 02-01-2010 12:57 PM

Quote:

Originally Posted by HasC (Post 3848567)
Not really sure of what exactly you're wanting, but:

Code:

$ grep Foo file|grep -v BlahFoo
could do the trick. Or, another example:

Code:

$ egrep '/ Foo /' file
(notice the blank spaces)


For some reason my grep brings back Both BlahhFoo and Foo. I want it to only return Foo.

chrism01 02-01-2010 05:36 PM

This should work as per your requirements
Code:

grep Foo file|grep -v BlahFoo
Please show an example of the file's content and define exactly what you want to see.


All times are GMT -5. The time now is 11:02 PM.