Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-14-2014, 04:21 AM   #1
LQ Newbie
Registered: Jul 2014
Distribution: Ubuntu 12.04 Precise
Posts: 5

Rep: Reputation: Disabled
Grep on catdoc


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
Old 07-14-2014, 07:02 AM   #2
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

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

find . -iname "*.doc" -print0 | while read -d $'\0' file; do catdoc "$file" | grep -i -w -f ~tmp/test.txt && echo ::: $file; done
Old 07-14-2014, 08:32 AM   #3
LQ Newbie
Registered: Jul 2014
Distribution: Ubuntu 12.04 Precise
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you very much for the quick reply. This works fine.


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 to file outputs more than grep to screen? tcpman Linux - Server 4 06-07-2013 04:46 AM
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 02:07 PM
catdoc problum sriphp Linux - Software 5 05-09-2009 05:12 AM
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 10:31 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:47 PM.

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