Open new file from command line?

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!

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

You can surround inline code with backticks (`), and indent block code with four spaces, like this:

block code goes here

Alternatively, use triple backticks on the lines above and below your code like so:

more block code

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.

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.

I recently faced the same problem, and while Libreoffice can’t normally achieve this, I found the following workaround sufficient:

touch file.txt
libreoffice --convert-to docx file.txt
libreoffice file.docx

Essentially, the first command creates file.txt, which, via the second command, is converted to a blank *.docx file which is then opened in the third command. Note that you can use other formats by changing the --convert-to argument in the second command. Cheers!