Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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. – 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. – 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. :-)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .