MacOS – How to open a file in its default application from the command line in OS X

command linemacosuti

How can I open a file in its default application from the command line?

For example if I have a file foo.doc, can I type command ./foo.doc into the CLI and have that file open in Word?

Note: on my linux machine, I would use xdg-open but that doesn't work on my Mac.

Best Answer

Use:

open foo.doc

or, alternatively:

open -n foo.doc

to force it to open a new instance if one is already open for that app.