LinuxQuestions.org
Help answer threads with 0 replies.
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-15-2014, 08:35 AM   #1
ns1971
LQ Newbie
 
Registered: Jul 2014
Distribution: Ubuntu 12.04 Precise
Posts: 5

Rep: Reputation: Disabled
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
 
Old 07-15-2014, 08:58 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,147

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
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
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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.
 
Old 07-15-2014, 10:39 AM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
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.
 
  


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
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

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

All times are GMT -5. The time now is 04:39 PM.

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