Ask Your Question
0

Open new file from command line?

asked 2015-03-06 16:06:11 +0200

juanm gravatar image

updated 2015-03-06 16:08:01 +0200

It is very common on Linux to do

command filename

from the command line, and programs will try to open the file called filename or, if it does not exist, create it. However, when I do

libreoffice spread.ods

I get an error saying that the file does no exist. Additionally, if just open libreoffice from the command line without specifying a filename and then open the save-file dialog, the default location is not the directory from where I issued the command, but my home. I find these behaviour inconvenient for my workflow... Is there any way to create a new empty file from command line and open it directly?

Thanks!

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
0

answered 2018-09-21 05:26:49 +0200

What I have always found helpful is to create an empty document from command line and then call LibreOffice on it. For example,
touch new_file.odt
libreoffice --writer new_file.odt

or you can use them together and type in
touch new_file.odt && libreoffice --writer new_file.odt

or you can use lowriter if you want as well.
lowriter new_file.odt

edit flag offensive delete link more
0

answered 2018-05-04 16:53:51 +0200

If I'm in my terminal in Linux and I want to open an odt file I just type lowriter then the file name. For example, if I want to open the file pizza.odt through the terminal I would type: lowriter pizza.odt and the file will open in Libre Writer.

edit flag offensive delete link more
0

answered 2018-05-04 18:06:11 +0200

carnish gravatar image

updated 2018-05-04 18:10:03 +0200

I have an alias in the alias file that is sourced when I open a terminal.

alias writer='/usr/bin/libreoffice --writer --norestore &>writer.log'

So

writer mydoc.odt &

will open the file in writer.

In Ubuntu and Solaris the alias file is ~/.bash_aliases by default. Other distros may be different. In Debian I had to modify the ~/. profile file.

The --norestore bypasses the document recovery process which for me always otherwise runs and has never been necessary. If it turns out that a document does need recovery then you can run writer without this switch.

The redirect of output '> ' spares me from warnings and errors that are rarely important but will be put to the writer.log file if something goes awry.

edit flag offensive delete link more
0

answered 2015-08-05 09:26:45 +0200

Rolf23 gravatar image

There appears to be no option available, which is something of an oversight.
However, create a blank document of the type that you wish to use and save it i.e. mybase.odt or mybase.ods
Then on the command line
cp mybase.odt mynewfilename.odt
or
cp mybase.ods mynewfilename.ods

and then
libreoffice mynewfilename.odt
or
localc mynewfilename.ods

edit flag offensive delete link more

Comments

In order to create a blank document wouldn't it be much better to just use the touch command and then call LibreOffice on it

abhijithnraj gravatar imageabhijithnraj ( 2018-09-21 05:28:49 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-03-06 16:06:11 +0200

Seen: 10,627 times

Last updated: Sep 21 '18