- Открытие doc, docx, odf, xlsx файла в терминале linux
- 3 ответа 3
- How to open Microsoft Word documents in Linux
- LibreOffice
- Installing LibreOffice
- Debian 8, Ubuntu 15
- Fedora 23
- OpenSUSE 10
- CentOS 7
- Arch Linux 2016
- AbiWord
- Installing AbiWord
- Debian 8, Ubuntu 15
- Fedora 23
- OpenSUSE 10
- CentOS 7
- Arch Linux 2016
- Antiword
- Using Antiword
- Installing antiword
- Debian 8, Ubuntu 15
- Fedora 23
- OpenSUSE 10
- CentOS 7
- Docx2txt
- Debian 8
- Ubuntu 15
- Fedora 23
- OpenSUSE 10
- CentOS 7
- Arch Linux 2016
- Installing Microsoft-compatible fonts
- Debian 8, Ubuntu 15
- Fedora 23
- OpenSUSE 10
- CentOS 7
- Arch Linux 2016
- Related information
- How to open word document file in terminal?
- 5 Answers 5
Открытие doc, docx, odf, xlsx файла в терминале linux
Вопрос заключается в следующем: «Существует ли такие программы, позволяющие открыть doc, docx, odf файлы в терминале linux?». Понимаю, что теоретически это не возможно, в силу отсутствие возможности программной смены шрифта в терминале. Но! Что если, мне нужно, к примеру, тупо прочитать текст из файла, а под рукой нету десктопной машины? Или можно такой вариант: программа преобразовывает doc, docx, odf файл в tex-файл. P.S.: я так полагаю, что этот вариант открытия подобных файлов будет еще и экономнее десктопного относительно памяти. С xlsx и подобными этому файлами тоже такой же вопрос встревает. Папа как-то рассказывал просто, что когда еще не было десктопных осей и граф оболочек, они использовали вместо doc-ов какую-то dos-овскую консольную прогу, и какие-то таблицы вместо excel-ей. Буду благодарен за ответ. UPD: Вопрос закрыт
3 ответа 3
Когда не было графических оболочек, тогда и и форматы были другие. Чем-то отчасти похожие на современный markdown
Файлы же конечно можно прочитать. Но именно прочитать — предварительно конвертировав в текстовый формат. Так Excel файлы можно перевести в CSV — а дальше смотри хоть в less, хоть awk или sed дальше преобразуй.
Файл Word конвертируются в обычный TXT — только текст и никакого форматирования. Можно и в RTF — тут оформление сохранится, но чтобы их читать нужен определенный навык 🙂
А с практической точки зрения задача довольно актуальная. Постоянно приходится решать задачи типа «У нас есть прайс-лист в Excel — мы хотим его автоматически загружать на сайта в базу данных». Соответственно помимо утилит консоли есть и куча библиотек под разные языки программирования — позволяющих открыть, прочитать, изменить и сохранить файлы этих форматов без взякого GUI.
How to open Microsoft Word documents in Linux
In an office or production environment, sharing documents between different applications and operating systems is a common issue. If you need to create, open, and edit Microsoft Word documents in Linux, you can use LibreOffice Writer or AbiWord. Both are robust word processing applications that read and write files in Word .doc and .docx formats.
If you need command-line tools that extract the text from Word files, Antiword (.doc files) and docx2txt (.docx) are useful programs to have at your disposal.
In this tutorial, we look at these four applications and how you can use them. We walk through installing them on several popular Linux distributions, including Debian, Ubuntu, Fedora, OpenSUSE, CentOS, and Arch Linux. We also help with installing the core Microsoft TrueType fonts on your Linux system.
LibreOffice
LibreOffice is a free, open-source, actively maintained and frequently updated office productivity suite that is compatible with Microsoft Office applications, including Microsoft Word. You can save your LibreOffice Writer documents in .doc or .docx format, and then either opens correctly in Microsoft Word.
Installing LibreOffice
LibreOffice can be installed using your package manager. To install it, open a terminal and use the following command appropriate for your operating system:
Debian 8, Ubuntu 15
sudo apt-get update && sudo apt-get install libreoffice
Fedora 23
sudo dnf update && sudo dnf install libreoffice
OpenSUSE 10
sudo zypper refresh && sudo zypper install libreoffice
CentOS 7
sudo yum update && sudo yum install libreoffice
Arch Linux 2016
sudo pacman -Sy libreoffice-fresh
Once LibreOffice is installed, it should appear in the Applications menu of your GUI. You can also run it from a terminal with the command:
AbiWord
AbiWord is another free and open-source word processor. It has a clean, simple interface developed for almost twenty years. Like LibreOffice, it can open, edit, and save Microsoft Word .doc and .docx files. Unlike LibreOffice, Abiword is not a complete office suite, so it has a smaller footprint and consumes fewer system resources.
Installing AbiWord
Debian 8, Ubuntu 15
sudo apt-get upgrade && sudo apt-get install abiword
Fedora 23
sudo dnf update && sudo dnf install abiword
OpenSUSE 10
sudo zypper refresh && sudo zypper install abiword
CentOS 7
sudo yum update && sudo yum install abiword
Arch Linux 2016
Antiword
Antiword is a command-line tool that converts the contents of a .doc file to plain text.
Antiword only converts .doc files. If you need to convert a .docx file, see docx2txt in the next section.
Using Antiword
Running antiword with the name of a Word .doc file outputs the plain text of the file to standard output.
Antiword does a great job of formatting tables. It also has options for including images as PostScript objects and outputting to PDF.
You can redirect the output to a text file:
antiword file.doc > file.txt
Or, if you want to open it directly in a text editor, you can pipe the text to vim:
Installing antiword
Debian 8, Ubuntu 15
sudo apt-get update && sudo apt-get install antiword
Fedora 23
sudo dnf update && sudo dnf install antiword
OpenSUSE 10
sudo zypper refresh && sudo zypper install antiword
CentOS 7
sudo yum update && sudo yum install antiword
Docx2txt
Docx2txt is a command-line tool that converts .docx files to plain text. (It does not convert .doc files.)
To print the contents of a .docx file to the terminal screen or a file, call docx2txt and specify a dash as the output file name. In this example, notice the dash at the end of the command.
To convert a .docx file and output to a text file, use the command form:
docx2txt file.docx file.txt
docx2txt file.docx - > file.txt
To open the .docx text in vim, use the command form:
To install doc2txt, follow the instructions for your version of Linux below:
Debian 8
sudo apt-get update && sudo apt-get install docx2txt
Ubuntu 15
sudo apt-get update && sudo apt-get install docx2txt
Fedora 23
Fedora’s repositories do not offer a package for docx2txt, but you can install it manually:
Download the source from SourceForge’s docx2txt page. Extract the archive:
You need to make sure that perl, unzip and make are installed on your system, so install or upgrade those packages now:
sudo dnf update && sudo dnf install perl unzip make
Then, run make as the root user to install:
Docx2txt is now installed as docx2txt.sh. For instance, to convert the file word-document.docx to a text file, you can run:
docx2txt.sh word-document.docx
The converted text file automatically saves as word-document.txt.
OpenSUSE 10
SUSE repositories do not offer a package for docx2txt, but you can download it from SourceForge’s docx2txt page. Extract the archive:
You need to make sure that perl, unzip and make are installed on your system, so install or upgrade those packages now:
sudo zypper update && sudo zypper install perl unzip make
Then, run make as root to install:
Docx2txt is now installed as docx2txt.sh. For instance, to convert the file word-document.docx to a text file, you can run:
docx2txt.sh word-document.docx
The converted text file is automatically saved as word-document.txt.
CentOS 7
CentOS repositories do not offer a package for docx2txt, but you can download it from SourceForge’s docx2txt page. Extract the archive:
You need to make sure that perl, unzip and make are installed on your system, so install or upgrade those packages now:
sudo yum update && sudo yum install perl unzip make
Then, run make as root to install:
Docx2txt is now installed as docx2txt.sh. For instance, to convert the file word-document.docx to a text file, you can run:
docx2txt.sh word-document.docx
The converted text file is automatically saved as word-document.txt.
Arch Linux 2016
Installing Microsoft-compatible fonts
The core Microsoft fonts are available on Linux. Install them if you are going to be working with Microsoft Word files — especially if they were created on a Windows system. The core fonts include:
- Andale Mono
- Arial
- Arial Black
- Calabri
- Cambria
- Comic
- Courier
- Impact
- Times
- Trebuchet
- Verdana
- Webdings
To install them, follow these steps:
Debian 8, Ubuntu 15
sudo apt-get update && sudo apt-get install ttf-mscorefonts-installer
Fedora 23
Install packages required for installation:
sudo dnf update && sudo dnf install curl cabextract xorg-x11-font-utils fontconfig
Then install the local RPM package:
sudo dnf install msttcore-fonts-installer-2.6-1.noarch.rpm
OpenSUSE 10
Install packages required for installation:
sudo zypper update && sudo zypper install curl cabextract xorg-x11-font-utils fontconfig
Then install the local RPM package:
sudo zypper install msttcore-fonts-installer-2.6-1.noarch.rpm
CentOS 7
Install packages required for installation:
sudo yum update && sudo yum install curl cabextract xorg-x11-font-utils fontconfig
Then install the local RPM package:
sudo yum install msttcore-fonts-installer-2.6-1.noarch.rpm
Arch Linux 2016
Install packages required for installation:
pacman -Sy rpmextract x11-font-utils fontconfig
Extract the contents of the local RPM package:
rpmextract.sh msttcore-fonts-installer-2.6-1.noarch.rpm
This command extracts the raw contents of the RPM file and creates two directories, etc and usr that correspond to your /etc and /usr directories. The font files themselves are located in usr/share/fonts/msttcore.
Related information
How to open word document file in terminal?
As I’m trying to open a word document from the terminal, i used wvWare and some other commands for the same, but i couldn’t get it. Could any one please help me out!
5 Answers 5
Technically speaking xdg-open should work for all file types. It’ll just open them in the appropriate application. All the document mime types are mapped to Libre Office by default so this should just work:
Works for me (on Ubuntu 16.04). Upvoted this answer because I want the command line equivalent of finding the file in the file manager application and double-clicking it. I shouldn’t have to remember the application executable name ( lowriter in the accepted answer).
You can open it with help of libre-office-writer by following command (open with libre office writer):
Name libreoffice - LibreOffice office suite SYNOPSIS libreoffice [--accept=accept-string] [--base] [--calc] [--convert-to output_file_extension[:output_filter_name] [--outdir output_dir] file]. [--display display] [--draw] [--global] [--headless] [--help|-h|-?] [--impress] [--invisible] [--infilter=""] [--math] [--minimized] [-n file]. [--nodefault] [--nolockcheck] [--nologo] [--norestore] [-o file]. [-p file. ] [--print-to-file [--printer-name printer_name] [--outdir output_dir] file]. [--pt printername file. ] [--show Impress file]. [--unaccept=accept-string] [--terminate_after_init] [--view file]. [--web] [--writer] [file. ] lobase localc lodraw lofromtemplate loimpress lomath loweb lowriter DESCRIPTION LibreOffice (LO for short) is a multi-platform office productivity suite.