Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a command line tool that is able to search .docx file under MS DOS or Cygwin ?

I have tried Grep, it's not working with .docx while working fine with .txt file.

I know I could always convert the .docx to .txt 1st then search using Grep, but I am wondering:

Is there a command tool that I can search directly under command line?

OP edit: Later I found out that the easiest way to achieve the grep is actually to convert those docx to txt then grep over them.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

There are many libraries allowing to read or otherwise manipulate DOCX files. Thinking of Apache POI, or python-docx, for example. I don't know if there is already a wrapper which would allow you to grep a DOCX, but that would most certainly not be too hard to do using POI (I have no experience with python-docx. It might still be a faster solution.).

EDIT:

Also, simpler, you might unzip the DOCX (because it's really just a ZIP file), and grep through the content, as suggested here.

share|improve this answer
    
thanks for the links but are they command line utilitys ? –  Gob00st Jan 6 '12 at 16:08
    
General advice: try keeping a text version of your document source. Be it LaTeX, XML, raw text, or other easily parsable formats. Helps a lot for version control and searching through many files. –  M. Joanis Jan 6 '12 at 16:09
    
@Gob00st: Well, for the last suggestion, if you have a command-line unzip, you're good to go. I just checked with my cygwin installer and you can install unzip anytime to complete the unzip+grep toolchain. –  M. Joanis Jan 6 '12 at 16:11
    
thanks for the advice, but this is not for my project, just trying to search some text in some MS documents faster without need to open each and every one of them. –  Gob00st Jan 6 '12 at 16:15
    
@M: I didn't know it's a zip file... But I have just unzipped one docx file and now it's more like xmls files. The thing is I want to be able to search over a lot docx files , that's why I was trying to use grep which works great when I search a lot xml/txt files... –  Gob00st Jan 6 '12 at 16:19

I used to use antiword/catdoc for this purpose. There has obviously been some work on expanding the functionality to include docx files as well. :-) http://blog.kiddaland.net/2009/07/antiword-for-office-2007/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.