theshell.ch/site/pages/cmd/basic/open.html
devitg d2d1d75763 Team Basic: Adding openshell and commands man, open, say
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@73 a672b425-5310-4d7a-af5c-997e18724b81
2018-11-09 13:06:37 +00:00

76 lines
2.4 KiB
HTML

---
layout: page
author: De Vita Gianmarco
title: OPEN
---
<p>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.
</p>
<pre>
Device-name:Current-position username$ open path/name-file
</pre>
<h3>Open a file with a specific application</h3>
<p>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.
</p>
<pre>
Device-name:Current-position username$ open -a application-name path/name-file
</pre>
<h4>Example</h4>
<p>Assume that I want to open with <i>Preview</i> the file
<code>abc.pdf</code> on my Desktop.
I have to write:
</p>
<pre>
User-Device:~ user$ open -a preview Desktop/abc.pdf
</pre>
<p>As result, a new <i>Preview</i> window appears in pop up showing the content of the
chosen file.
</p>
<h3>Open a file with <i>TextEdit</i></h3>
<p>If you want to open a file with TextEdit, just use instead of <code>-a</code>
the flag <code>-e</code> and write the path and the name of the file you want
to open.</p>
<pre>
User-Device:~ user$ open -e Desktop/text.txt
</pre>
<h3>Open the folder which contains the file</h3>
<p>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.
</p>
<pre>
User-Device:~ user$ open -R Desktop/text.txt
</pre>
<p>As result, a new <i>Finder</i> window opens the folder displaying its content.</p>
<h3>Open a file as a text</h3>
<p>If you want to open a file with your default text editor (determined via
LaunchServices), just use the flag <code>-t</code> and write the path and the name of
the file you want to open.</p>
<pre>
User-Device:~ user$ open -t Desktop/text.txt
</pre>
<h3>Visit a Website</h3>
<p>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 <code>URL</code> of the page
you want to visit. For example, by typing the command</p>
<pre>
User-Device:~ user$ open http://www.google.com
</pre>
<p>A new page of your default browser will open on the indicated page (in this
example, the main page of the Google Search Engine). </p>