0d12727e7f
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@86 a672b425-5310-4d7a-af5c-997e18724b81
55 lines
984 B
HTML
55 lines
984 B
HTML
---
|
|
layout: page
|
|
category-page: scripts
|
|
category-title: Scripting
|
|
tags: reditect output input
|
|
author: Dario Rasic
|
|
title: Redirection
|
|
---
|
|
|
|
<h2>Output as input</h2>
|
|
|
|
<p>To redirect a certain output of the command-line we have to use the symbol ">".<br>
|
|
|
|
In this case, we will use a file named "<i>hello.txt</i>", in which we want to insert
|
|
a certain output ("Sun" in this case):<br>
|
|
|
|
<pre>
|
|
echo "Sun" > hello.txt
|
|
</pre>
|
|
|
|
So if we print the content of the file in our command-line, the output will be the following:
|
|
<pre>
|
|
cat hello.txt
|
|
Sun
|
|
</pre>
|
|
|
|
If we want to append a certain output to an existing file,
|
|
we just have to use ">>" symbols:</p>
|
|
|
|
<pre>
|
|
cat hello.txt
|
|
Sun
|
|
echo "Moon" >> hello.txt
|
|
cat hello.txt
|
|
Sun
|
|
Moon
|
|
</pre>
|
|
|
|
<h2>Input as output</h2>
|
|
|
|
To redirect an input from a file for a command, the symbol "<" is used.
|
|
|
|
<pre>
|
|
echo < $(cat hello.txt)
|
|
Sun
|
|
Moon
|
|
</pre>
|
|
|
|
This is particularly useful when chaining commands.
|
|
|
|
<h2>Chaining</h2>
|
|
|
|
<h1>To be completed</h1>
|
|
|
|
</p>
|