Open a file or folder.
The open command opens a file (or a folder or URL), just as if you had double-clicked the file's icon.
Syntax open [options] [-b bundle_identifier] [-a application] file ... [--args arg1 ...] Key -a application The application to use for opening the file -b bundle_indentifier The bundle identifier for the application to use when opening the file. -D Reveal the enclosing folder in finder. -e Open the file with /Applications/TextEdit -t Open the file with the default text editor, as determined via Launch-Services -f Read input from standard input and open 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. -F Open the application "fresh," that is, without restoring windows. Saved persistent state is lost, except for Untitled documents. -W Wait until the applications exit (even if they were already open). Use with the -n flag to allow open to function as an appropriate app for the $EDITOR environment variable. -R Reveal the file(s) in the Finder instead of opening them. -n Open a new instance of the application(s) even if one is already running. -g Do not bring the application to the foreground. -h Search header locations for a header whose name matches the given string and then open it. Pass a full header name (such as NSView.h) for increased performance. --args 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.
If no application name is specified, the default application as determined via LaunchServices is used to open the specified files.
You can specify one or more file names (or pathnames), which are interpreted relative to the shell or Terminal window's current working directory. e.g. open *.doc
Open the current terminal working directory:
$ open .
Open demo.txt in the default application (as determined by LaunchServices):
$ open demo.txt
$ open /Volumes/Macintosh HD/demo.txt
$ open file://localhost/Volumes/Macintosh HD/demo.txt
Reveal in finder, the enclosing folder for a directory or file:
$ open -D demo.txt
Open a folder in the Mac Finder:
$ open /Volumes/Macintosh HD/Applications/
$ open ~/Library/Spelling/
This can also be done with a full path:
$ open file://localhost/Volumes/Macintosh HD/Applications/
Open demo.txt with a specific application (in this case, TextEdit):
$ open -a /Applications/TextEdit.app /Volumes/Macintosh HD/demo.txt
Open a URL:
$ open https://ss64.com/
Pipe the output of cal into TextEdit:
$ cal | open -a TextEdit -f
Edit demo.txt (will open in TextEdit):
$ open -e /Volumes/Macintosh HD/foo.txt
“Clothes make the man. Naked people have little or no influence on society” ~ Mark Twain
echo - Display message on screen.
Article: TA24770 - Clear the Finder "Open With" contextual menu (rename /Library/Preferences/com.apple.LaunchServices.plist).