LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Grep for word documents (https://www.linuxquestions.org/questions/linux-newbie-8/grep-for-word-documents-4175511157/)

ns1971 07-15-2014 08:35 AM

Grep for word documents
 
Hi

I have 10 (.doc) files and out of that 7 files has got a specific word I am looking for. But when I run the grep command it only outputs 5 files and not all the 7 files.

e.g. grep -i -w -f 'smith'

Please can somebody explain why it does not work on all word documents.

Many thanks

smallpond 07-15-2014 08:58 AM

I'm surprised it worked on any. You're looking for an ASCII string in UTF-16 data.

ondoho 07-15-2014 10:34 AM

i wonder what the "-f" switch is doing there.
Quote:

Originally Posted by man grep
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file
contains zero patterns, and therefore matches nothing. (-f is
specified by POSIX.)

how exactly did you search for the word inside those documents?
word documents contain the written text in plain text, more or less, afaik, but the "-w" option might block some results, e.g. if the word is followed immediately by some weird character, without a space in between.

szboardstretcher 07-15-2014 10:39 AM

http://www.irongeek.com/i.php?page=b...k-3-man/catdoc

Use catdoc to 'cat' the Word file and 'grep' through the resulting output.


All times are GMT -5. The time now is 05:25 PM.