Ubuntu – How to “cat” or “less” a libreoffice writer .odt file

libreofficetext processing

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

Best Answer

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.

Related Question