I use LibreOffice Writer a lot, but I really do hate getting around in a GUI, I much prefer the CLI, so is there any way to open a file using LibreOffice Writer through the Terminal?
Asked
Active
Viewed 1.6e+01k times
64
-
1Nearly a duplicate of http://askubuntu.com/questions/80977/how-does-one-find-out-the-command-line-corresponding-to-gui-app-eg-libreoffice. – Jos Aug 10 '15 at 12:28
-
`libreoffice --help` @pilot6 answer also works for `calc`, `draw`, `base` – Rinzwind Aug 10 '15 at 12:29
-
@ParanoidPanda xdg-open? – αғsнιη Jul 09 '17 at 03:18
3 Answers
81
You can do it by
libreoffice --writer file.odt
If it is an odt file, you can open it just by
libreoffice file.odt
Some file formats can be opened by different LO applications, then you need to specify which one to use.
Pilot6
- 88,764
- 91
- 205
- 313
-
1
-
2If its a csv or xls file then ` libreoffice --calc /path/to/file.csv`. You can get more info by `man libreoffice` – Sohel Ahmed Mesaniya Nov 18 '16 at 09:14
-
1To launch a brand new file like this you need to first create it, `touch file.odt && libreoffice --writer file.odt` – cardamom Sep 19 '17 at 11:06
-
If you want a new file, there is no need to `touch` it. You can just start `libreoffice --writer` then save the file after you edit it. – Pilot6 Sep 19 '17 at 11:09
-
I get an error when opening files straight with the --writer option. but when i run touch first it works fine. – john-jones Oct 25 '18 at 12:17
-
1For later versions and/or manually-installed versions, you may need to include the version number. In my case, it is required to be done as follows: `libreoffice6.1 --writer` – Gabriel Staples Feb 01 '19 at 18:00
-
For my Mac installation there's no libreoffice command in my $PATH and `find /Applications/LibreOffice.app/ -name 'libreoffice*'` comes up empty. – hobs Nov 18 '19 at 19:05
-
4
The more general solution is xdg-open. This not only works for LibreOffice documents, but for any file or URL:
xdg-open file-or-url
opens file-or-url using your preferred application.
If you normally work from the terminal, then having alias o=xdg-open in ~/.bash_aliases makes life simple:
o my-document.odt
o https://askubuntu.com
You may then also enjoy sr (surfraw) for rapid web searches from the command-line.
zwets
- 11,795
- 2
- 32
- 44
1
In case you need to open a file in LibreOffice in read-only mode it's
libreoffice --view file.odt
cardamom
- 123
- 8