Tool for viewing LibreOffice Writer files in terminal window

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.


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

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