20

I am using a couple of documentation files in LibreOffice (.odt) format. Normally, I access them with LibreOffice Writer of course. But there are times when I can only connect to the site with a text terminal.

I am wondering if there is a terminal-based tool that can show me the contents of these files in approximate correct format? (The files mainly contain simple text, bullet lists, and a few 1x1 tables, so it's relatively simple stuff in terms of formatting.)

P.S. This question is not about starting LibreOffice itself from the command line (which is anwered here).

rookie09
  • 303

4 Answers4

23

libreoffice provides a --convert-to option which can be used to convert a document to e.g. text or html:

  • convert input.odt to input.txt:
    libreoffice --convert-to "txt:Text (encoded):UTF8" input.odt

  • convert every .odt in the current directory to .html:
    libreoffice --convert-to "html:XHTML Writer File:UTF8" *.odt

  • convert every .ods in the current directory to .csv:
    libreoffice --convert-to csv *.ods

The output can be opened with the pager or terminal browser of your liking: less, most or w3m to list just three.

dessert
  • 40,956
22

There is a tool called odt2txt that can convert odt to txt.

Compared to libreoffice I can see two benefits:

  • Lightweight if you don't have libreoffice installed (e.g. on a server)
  • It can print to stdout for direct viewing of files.

Installation:

sudo apt install odt2txt

Then you can directly view an odt:

odt2txt document.odt | less
pLumo
  • 27,991
12

LibreOffice has a --cat option which exists in version 5.1 but not 4.2. Not sure exactly when it was introduced.

libreoffice --cat "Untitled 1.odt" --headless | less

For more information:

libreoffice --help
Jim K
  • 1,423
0

Another tool that you can use is unoconv which can convert "between any document format supported by LibreOffice/OpenOffice"

unoconv -f txt my.odt
phuclv
  • 760