Tool for viewing LibreOffice Writer files in terminal window

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

4

4 Answers

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.

2

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
1

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
1

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

unoconv -f txt my.odt

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like