Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 10 down vote accepted

open foo.doc, or open -n foo.doc to force it to open a new window if one is already open for that app.

share|improve this answer
open is a very good command to get to know. – CajunLuke Aug 15 '12 at 16:34
open -n opens a new instance, not a window. – user495470 Aug 15 '12 at 16:37
Also nice is open . (or any directory name in place of .), which opens Finder (the default application for a directory). – Nathan Long Aug 15 '12 at 17:03
where could I set default preferred program that open opens for specific file type? ( it would be great if this preference stored somewhere, cause setting it by gui is very annoying ) – gaussblurinc Feb 25 at 12:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.