17

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,418
  • 7
  • 53
  • 72
DQdlM
  • 1,068
  • 4
  • 14
  • 27

1 Answers1

20

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
  • 14,465
  • 4
  • 54
  • 70
Jason
  • 1,223
  • 1
  • 10
  • 13