26

Is there a way to cat or less a .odt file just as antiword does for .doc files?

35

The solution is using odt2txt. Now, this command is provided by two different packages, namely one called odt2txt that you can install with

sudo apt-get install odt2txt 

and by the package unoconv (that offers also command-line conversions between more libreoffice formats), that is installed by

sudo apt-get install unoconv

If you have the two, you can switch between them using the alternative mechanism:

sudo update-alternatives --config odt2txt

If you are using the odt2txt provided by the package odt2txt you just use

odt2txt file.odt

if using the unoconv provided package you have to use

odt2txt --stdout file.odt

Pipe them to less to have a less-like experience (odt2txt file.odt | less)

Notice that if you do not use the --stdout option, the unoconv-provided package will write the result in a file called file.txt.

The suggested package by the distribution seems to be the one from the odt2txt package (it has a higher default priority in the alternative system); for sure it has less dependencies.

  • Fantastic, thank you! Yes, I've installed the odt2txt package and it behaves as it should. – Avio Nov 7 '14 at 13:26
  • The problem with unoconv, as I have discovered, is that it wants to install an older version of Libre Office if you have a newer one installed. Therefore, stick with sudo apt install odt2txt. – Paddy Landau Nov 11 '14 at 17:43
  • @PaddyLandau I heavily edited the answer, thank for the hint. – Rmano Nov 11 '14 at 18:12
  • @Rmano You have also taught me about update-alternatives, thank you. – Paddy Landau Nov 12 '14 at 5:51
7

You can browse through text without any special utility. ODT file is a renamed zip archive. Unzip it and you will see several files. One of them, content.xml contains all text and is more or less readable.

6

odt2txt file.odt

the source code and compilebale working zip can be downloaded here:

https://github.com/dstosberg/odt2txt/

or installed by sudo apt-get install odt2txt

2

You can't cat or less or more an .odt file because it's a binary file. It's actually - as was said earlier - a renamed .zip archive, so you have to extract the content.xml file, but that, as it implies, is an XML document, so you have to process it as such to extract the information out of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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