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).
44 Answers
libreoffice provides a --convert-to option which can be used to convert a document to e.g. text or html:
convert
input.odttoinput.txt:libreoffice --convert-to "txt:Text (encoded):UTF8" input.odtconvert every
.odtin the current directory to.html:libreoffice --convert-to "html:XHTML Writer File:UTF8" *.odtconvert every
.odsin 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 odt2txtThen 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 | lessFor 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