18

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.

Cajunluke
  • 17,704
DQdlM
  • 1,078

1 Answers1

21

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.

jaume
  • 15,010
Jason
  • 1,233