LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grep on catdoc (https://www.linuxquestions.org/questions/linux-newbie-8/grep-on-catdoc-4175511028/)

ns1971 07-14-2014 04:21 AM

Grep on catdoc
 
Hi

I am new to using linux. I am trying to use catdoc grep for a list of phrases on word documents.

The syntax below gives me the matches found in the document but not the file name. Please can anybody help me with the syntax that will show the file name and the matches found.

find . -iname "*.doc" -print0 | while read -d $'\0' file; do catdoc "$file" | grep -i -w -f ~tmp/test.txt; done

Many thanks

linosaurusroot 07-14-2014 07:02 AM

This adds a "&& echo ::: $file" to the command:

Code:

find . -iname "*.doc" -print0 | while read -d $'\0' file; do catdoc "$file" | grep -i -w -f ~tmp/test.txt && echo ::: $file; done

ns1971 07-14-2014 08:32 AM

Thank you very much for the quick reply. This works fine.


All times are GMT -5. The time now is 03:49 PM.