OPEN(1) General Commands Manual OPEN(1)

openopen files and directories

open [-e] [-t] [-f] [-F] [-W] [-R] [-n] [-g] [-j] [-h] [-u URL] [-s sdk] [-b bundle_identifier] [-a application] [--env VAR] [--stderr PATH] [--stdin PATH] [--stdout PATH] [--arch ARCH] [--args arg1 ...]

The open command opens a file (or a directory or URL), just as if you had double-clicked the file's icon. If no application name is specified, the default application as determined via LaunchServices is used to open the specified files.

If the file is in the form of a URL, the file will be opened as a URL.

You can specify one or more file names (or pathnames), which are interpreted relative to the shell or Terminal window's current working directory. For example, the following command would open all Word files in the current working directory:

open *.doc

Opened applications inherit environment variables just as if you had launched the application directly through its full path. This behavior was also present in Tiger.

The options are as follows:

Specifies the application to use for opening the file
Specifies the bundle identifier for the application to use when opening the file
Causes the file to be opened with the TextEdit application
Causes the file to be opened with the default text editor, as determined via LaunchServices
Reads input from standard input and opens the results in the default text editor. End input by sending EOF character (type Control-D). Also useful for piping output to open and having it open in the default text editor.
Opens the application "fresh," that is, without restoring windows. Saved persistent state is lost, except for Untitled documents.
Causes open to wait until the applications it opens (or that were already open) have exited. Use with the -n flag to allow open to function as an appropriate app for the $EDITOR environment variable.
Reveals the file(s) in the Finder instead of opening them.
Open a new instance of the application(s) even if one is already running.
Do not bring the application to the foreground.
Launches the app hidden.
ARCH
Launch with the given cpu architecture type and subtype; ARCH should be one of any, arm, arm64, arm64e, arm64_32, x86_64, x86_64h, i386. Two integers matching the values for cpu_type_t and cpu_subtype_t can be specified as integers separated by a '/' character, like "12/13" for CPU_TYPE_ARM/CPU_SUBTYPE_ARM_V8.
Searches header locations for a header whose name matches the given string and then opens it. Pass a full header name (such as NSView.h) for increased performance.
For -h, partial or full SDK name to use; if supplied, only SDKs whose names contain the argument value are searched. Otherwise the highest versioned SDK in each platform is used.
Opens URL with whatever application claims the url scheme, even if URL also matches a file path
All remaining arguments are passed to the opened application in the argv parameter to main(). These arguments are not opened or interpreted by the open tool.
VAR
Adds VAR to the environment of the launched application. VAR should be formatted NAME=VALUE or NAME.
PATH
Launches the application with stdin connected to PATH.
PATH
Launches the application with stdout connected to PATH.
PATH
Launches the application with stderr connected to PATH.

"open '/Volumes/Macintosh HD/foo.txt'" opens the document in the default application for its type (as determined by LaunchServices).

"open '/Volumes/Macintosh HD/Applications/'" opens that directory in the Finder.

"open -a /Applications/TextEdit.app '/Volumes/Macintosh HD/foo.txt'" opens the document in the application specified (in this case, TextEdit).

"open -b com.apple.TextEdit '/Volumes/Macintosh HD/foo.txt'" opens the document in the application specified (in this case, TextEdit).

"open -e '/Volumes/Macintosh HD/foo.txt'" opens the document in TextEdit.

"ls | open -f" writes the output of the 'ls' command to a file in /tmp and opens the file in the default text editor (as determined by LaunchServices).

"open http://www.apple.com/" opens the URL in the default browser.

"open 'file://localhost/Volumes/Macintosh HD/foo.txt'" opens the document in the default application for its type (as determined by LaunchServices).

"open 'file://localhost/Volumes/Macintosh HD/Applications/'" opens that directory in the Finder.

"open -h NSView" lists headers whose names contain NSView and allows you to choose which ones to open.

"open -h NSView.h" immediately opens NSView.h.

"open --env MallocStackLogging=YES -b com.apple.TextEdit" launches TextEdit with the environment variable "MallocStackLogging" set to "YES"

"open -h NSView -s OSX10.12" lists headers whose names contain NSView in the MacOSX 10.12 SDK and allows you to choose which ones to open.

First appeared in NextStep.

April 14, 2017 macOS