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.

0

1 Answer 1

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.

2
  • 4
    open -n opens a new instance, not a window.
    – Lri
    Commented Aug 15, 2012 at 16:37
  • 4
    Also nice is open . (or any directory name in place of .), which opens Finder (the default application for a directory). Commented Aug 15, 2012 at 17:03

Not the answer you're looking for? Browse other questions tagged .