Share your knowledge at the LQ Wiki.
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-15-2014, 08:35 AM   #1
LQ Newbie
Registered: Jul 2014
Distribution: Ubuntu 12.04 Precise
Posts: 5

Rep: Reputation: Disabled
Grep for word documents


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
Old 07-15-2014, 08:58 AM   #2
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,736

Rep: Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732
I'm surprised it worked on any. You're looking for an ASCII string in UTF-16 data.
1 members found this post helpful.
Old 07-15-2014, 10:34 AM   #3
LQ Addict
Registered: Dec 2013
Posts: 5,731

Rep: Reputation: 1346Reputation: 1346Reputation: 1346Reputation: 1346Reputation: 1346Reputation: 1346Reputation: 1346Reputation: 1346Reputation: 1346Reputation: 1346
i wonder what the "-f" switch is doing there.
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.
Old 07-15-2014, 10:39 AM   #4
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,184

Rep: Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585Reputation: 1585

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


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
Documents saved as MS Word documents Raggety Linux - Software 2 01-14-2009 02:16 PM
Q reg. word documents!! arunsri Linux - General 2 03-14-2005 06:42 PM
MS-Word Documents into MySQL dkroft Linux - Software 0 06-11-2004 01:45 PM
Concerning using word processors and opening documents sofasurfer Linux - Newbie 4 01-09-2004 12:13 AM

All times are GMT -5. The time now is 11:10 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