--- layout: page category-page: basic category-title: Basic commands tags: open author: Gianmarco De Vita title: open previous-page: pages/cmd/basic/openshell.html next-page: pages/cmd/basic/cd.html --- You can open files and folder as new windows through the terminal. The command is open. By writing the command open followed by the path and the name of the file (remember that you can omit the path if the file is in the current position), a new window in the common user interface opens. Now you can work on the opened file.
open path/name-file

Open a file with a specific application

Adding the flag -a to the command permit you to decide with which specific application open the file. Just write the flag followed by the name of the application.
open -a application-name path/name-file
Assume that you want to open the file abc.pdf on my Desktop using the program "preview".
open -a preview Desktop/abc.pdf
As result, a new Preview window appears showing the content of the chosen file.

Open the folder which contains the file

If you want to open the folder that contains a specific file, just use the flag -R and write the path and the name of the file you want to open.
open -R Desktop/text.txt
As result, a new Finder window opens the folder displaying its content.

Open a file with an editor

If you want to open a file with your default editor, just use the flag -t and write the path and the name of the file you want to open.
open -t Desktop/text.txt

Visit a Website

You can use this tool not only to open files and folders, but also webpages. Just write the command open followed by the URL of the page you want to visit.
open http://www.google.com
A new page of your default browser will open on the indicated page (in this example, the main page of the Google Search Engine).