LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-01-2010, 01:06 PM   #1
networkingnub
LQ Newbie
 
Registered: Jul 2009
Posts: 16

Rep: Reputation: 0
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

Last edited by networkingnub; 02-01-2010 at 01:28 PM.
 
Old 02-01-2010, 01:18 PM   #2
Mr-Bisquit
Member
 
Registered: Feb 2009
Distribution: FreeBSD, OpenBSD, NetBSD, Debian, Fedora
Posts: 770
Blog Entries: 52

Rep: Reputation: 68
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
 
Old 02-01-2010, 01:28 PM   #3
HasC
Member
 
Registered: Oct 2009
Location: South America - Paraguay
Distribution: Debian 5 - Slackware 13.1 - Arch - Some others linuxes/*BSDs through KVM and Xen
Posts: 329

Rep: Reputation: 55
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)
 
1 members found this post helpful.
Old 02-01-2010, 01:57 PM   #4
networkingnub
LQ Newbie
 
Registered: Jul 2009
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by HasC View Post
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.
 
Old 02-01-2010, 06:36 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,258

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Zgrep mulitple zip files tekvaio Linux - Newbie 1 09-25-2008 05:31 PM
Does zgrep unzip a file then grep it? bonz78 Linux - Newbie 3 08-05-2008 11:41 AM
beginner needs various help. meeep Linux - Software 44 08-21-2005 01:10 AM
Help this beginner weng Linux - Newbie 5 12-20-2003 09:55 AM
I am THE beginner please help me :( statuszero Linux - General 10 05-26-2002 04:44 PM


All times are GMT -5. The time now is 02:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration