2018-11-09 13:06:37 +00:00
|
|
|
---
|
|
|
|
layout: page
|
2018-11-11 11:00:42 +00:00
|
|
|
category-page: basic
|
2018-11-16 12:47:48 +00:00
|
|
|
category-title: Basic commands
|
2018-11-11 11:00:42 +00:00
|
|
|
tags: open
|
|
|
|
author: Gianmarco De Vita
|
|
|
|
title: open
|
2018-11-18 20:38:56 +00:00
|
|
|
previous-page: pages/cmd/basic/4-man.html
|
|
|
|
next-page: pages/cmd/basic/6-more-less.html
|
2018-11-09 13:06:37 +00:00
|
|
|
---
|
2018-11-15 20:09:21 +00:00
|
|
|
|
2018-11-12 10:47:50 +00:00
|
|
|
You can open files and folder as new windows through the terminal.
|
|
|
|
The command is <code>open</code>. 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.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
open path/name-file
|
2018-11-18 17:39:51 +00:00
|
|
|
</pre>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<h3>Open a file with a specific application</h3>
|
2018-11-12 10:47:50 +00:00
|
|
|
Adding the flag <code>-a</code> 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.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
open -a application-name path/name-file
|
2018-11-09 13:06:37 +00:00
|
|
|
</pre>
|
|
|
|
|
2018-11-12 10:47:50 +00:00
|
|
|
Assume that you want to open the file <i>abc.pdf</i> on my Desktop using the program "preview".
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
open -a preview Desktop/abc.pdf
|
2018-11-09 13:06:37 +00:00
|
|
|
</pre>
|
|
|
|
|
2018-11-12 10:47:50 +00:00
|
|
|
As result, a new <i>Preview</i> window appears showing the content of the
|
2018-11-14 08:56:17 +00:00
|
|
|
chosen file.<br>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-12 10:47:50 +00:00
|
|
|
<h3>Open the folder which contains the file</h3>
|
|
|
|
If you want to open the folder that contains a specific file, just use
|
|
|
|
the flag <code>-R</code> and write the path and the name of the file you want to open.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
open -R Desktop/text.txt
|
2018-11-09 13:06:37 +00:00
|
|
|
</pre>
|
|
|
|
|
2018-11-12 10:47:50 +00:00
|
|
|
As result, a new <i>Finder</i> window opens the folder displaying its content.<br><br>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
2018-11-12 10:47:50 +00:00
|
|
|
<h3>Open a file with an editor</h3>
|
|
|
|
If you want to open a file with your default editor,
|
|
|
|
just use the flag <code>-t</code> and write the path and the name of
|
|
|
|
the file you want to open.
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
open -t Desktop/text.txt
|
2018-11-14 08:56:17 +00:00
|
|
|
</pre>
|
2018-11-09 13:06:37 +00:00
|
|
|
|
|
|
|
<h3>Visit a Website</h3>
|
2018-11-12 10:47:50 +00:00
|
|
|
You can use this tool not only to open files and folders, but also webpages.
|
|
|
|
Just write the command <code>open</code> followed by the <i>URL</i> of the page
|
|
|
|
you want to visit.
|
|
|
|
|
2018-11-09 13:06:37 +00:00
|
|
|
<pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
open http://www.google.com
|
2018-11-09 13:06:37 +00:00
|
|
|
</pre>
|
2018-11-12 10:47:50 +00:00
|
|
|
|
|
|
|
A new page of your default browser will open on the indicated page (in this
|
|
|
|
example, the main page of the Google Search Engine).
|