LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 07-14-2014, 04:21 AM   #1
ns1971
LQ Newbie
 
Registered: Jul 2014
Distribution: Ubuntu 12.04 Precise
Posts: 5

Rep: Reputation: Disabled
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
 
Old 07-14-2014, 07:02 AM   #2
linosaurusroot
Member
 
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:

Code:
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
ns1971
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.
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:19 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
Open Source Consulting | Domain Registration