LinuxQuestions.org
Review your favorite Linux distribution.
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 12-16-2003, 01:49 PM   #1
skibud2
Member
 
Registered: Sep 2003
Location: Waltham MA
Distribution: Mandriva 2007 w/ KDE
Posts: 87

Rep: Reputation: 15
Using the results of locate for grep


Let's say that I do a locate command to find all txt files:
ex. locate .txt

How can I use the results in a grep command (to search what is in the files)?

For example: I use locate to find all text files and in each of those text files, I want to find the name "mike" with grep.

Thanks in advanced
-Mike
 
Old 12-16-2003, 01:58 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
This is one way:

locate *\.ksh | xargs grep -l 'mike'

The -l makes sure you only see a hit once.
 
  


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
grep ?? can grep us variables? DaFrEQ Linux - Software 4 09-14-2005 12:22 PM
cp files from grep results Sigkill(9) Linux - Newbie 2 08-22-2005 03:17 PM
Please help - Unpridictable results from grep/ps to find pid nharnwal Solaris / OpenSolaris 1 12-10-2003 08:28 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM
GREP a locate Hegemon Linux - Newbie 3 02-22-2002 04:04 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration