LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Using the results of locate for grep (http://www.linuxquestions.org/questions/linux-newbie-8/using-the-results-of-locate-for-grep-126389/)

skibud2 12-16-2003 01:49 PM

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

druuna 12-16-2003 01:58 PM

This is one way:

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

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


All times are GMT -5. The time now is 12:06 AM.