Let’s say you have edited a file in LibreOffice Writer, but later you access your computer remotely via SSH for example. You don’t really want to bother copying the file to your current machine, and rather just quickly check its content in the terminal. Is there a way?
Since odt files are just some zip files containing XML files, you could manually decompress the file, and open XML files, but there is a more convenient the program is called odt2txt. On an Ubuntu / Debian machine it can be installed with:
1 |
sudo apt-get install odt2txt |
For basic usage, you just need to pass the filename as parameter:
1 2 3 |
odt2txt test.odt This is a test |
But there are also a few more options:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
odt2txt odt2txt 0.4 Converts an OpenDocument or OpenOffice.org XML File to raw text. Syntax: odt2txt [options] filename Options: --raw Print raw XML --encoding=X Do not try to autodetect the terminal encoding, but convert the document to encoding X unconditionally To find out, which terminal encoding will be used in auto mode, use --encoding=show --width=X Wrap text lines after X characters. Default: 65. If set to -1 then no lines will be broken --output=file Write output to file, instead of STDOUT --subst=X Select which non-ascii characters shall be replaced by ascii look-a-likes: --subst=all Substitute all characters for which substitutions are known --subst=some Substitute all characters which the output charset does not contain This is the default --subst=none Substitute no characters --version Show version and copyright information |
This also wrote with ods (spreadsheets) and odp (presentations) files with ods2txt and odp2txt which are just symlinks pointing to the same program as odt2txt, namely odt2txt.odt2txt.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
odt2txt can also be used to diff documents stored in git.
https://git.wiki.kernel.org/index.php/GitTips#How_to_use_git_to_track_OpenDocument_.28OpenOffice.2C_Koffice.29_files.3
Openoffice has a headless mode too – not sure exactly what you can do with it:
$ soffice –help
LibreOffice 4.2.7.2 420m0(Build:2)
Usage: soffice [options] [documents…]
Options:
–minimized keep startup bitmap minimized.
–invisible no startup screen, no default document and no UI.
–norestore suppress restart/restore after fatal errors.
–quickstart starts the quickstart service
–nologo don’t show startup screen.
–nolockcheck don’t check for remote instances using the installation
–nodefault don’t start with an empty document
–headless like invisible but no userinteraction at all.
–help/-h/-? show this message and exit.
–version display the version information.
–writer create new text document.
–calc create new spreadsheet document.
–draw create new drawing.
–impress create new presentation.
–base create new database.
–math create new formula.
–global create new global document.
–web create new HTML document.
-o open documents regardless whether they are templates or not.
-n always open documents as new files (use as template).
–display
Specify X-Display to use in Unix/X11 versions.
-p
print the specified documents on the default printer.
–pt
print the specified documents on the specified printer.
–view
open the specified documents in viewer-(readonly-)mode.
–show
open the specified presentation and start it immediately
–accept=
Specify an UNO connect-string to create an UNO acceptor through which
other programs can connect to access the API
–unaccept=
Close an acceptor that was created with –accept=
Use –unnaccept=all to close all open acceptors
–infilter=
Force an input filter type if possible
Eg. –infilter=”Calc Office Open XML”
–convert-to output_file_extension[:output_filter_name] [–outdir output_dir] files
Batch convert files.
If –outdir is not specified then current working dir is used as output_dir.
Eg. –convert-to pdf *.doc
–convert-to pdf:writer_pdf_Export –outdir /home/user *.doc
–print-to-file [-printer-name printer_name] [–outdir output_dir] files
Batch print files to file.
If –outdir is not specified then current working dir is used as output_dir.
Eg. –print-to-file *.doc
–print-to-file –printer-name nasty_lowres_printer –outdir /home/user *.doc
–pidfile file
Store soffice.bin pid to file.
Remaining arguments will be treated as filenames or URLs of documents to open.