在终端窗口中查看 LibreOffice Writer 文件的工具

roo*_*e09 18 command-line text-editor libreoffice

我正在使用 LibreOffice ( .odt) 格式的几个文档文件。通常,我当然会使用 LibreOffice Writer 访问它们。但有时我只能使用文本终端连接到该站点。

我想知道是否有基于终端的工具可以以近似正确的格式向我显示这些文件的内容?(这些文件主要包含简单的文本、项目符号列表和一些 1x1 表格,因此在格式方面是相对简单的东西。)

PS 这个问题不是关于从命令行启动 LibreOffice 本身(这是 anwered here)。

des*_*ert 21

libreoffice提供了一个--convert-to选项,可用于将文档转换为例如文本或 html:

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

  • .odt当前目录中的每个转换为.html
    libreoffice --convert-to "html:XHTML Writer File:UTF8" *.odt

  • .ods当前目录中的每个转换为.csv
    libreoffice --convert-to csv *.ods

可以使用您喜欢的寻呼机或终端浏览器打开输出:lessmostw3m仅列出三个。


pLu*_*umo 21

有一个工具叫做odt2txt可以转换odttxt.

与 libreoffice 相比,我可以看到两个好处:

  • 如果您没有安装 libreoffice(例如在服务器上),则轻量级
  • 它可以打印到标准输出以直接查看文件。

安装:

sudo apt install odt2txt
Run Code Online (Sandbox Code Playgroud)

然后你可以直接查看一个odt

odt2txt document.odt | less
Run Code Online (Sandbox Code Playgroud)


Jim*_*m K 12

LibreOffice 有一个--cat存在于 5.1 版但不存在于 4.2 版的选项。不确定它是什么时候引入的。

libreoffice --cat "Untitled 1.odt" --headless | less
Run Code Online (Sandbox Code Playgroud)

想要查询更多的信息:

libreoffice --help
Run Code Online (Sandbox Code Playgroud)