theshell.ch/site/pages/scripts/redirection.html
rasicd 62f06e5131 modified layout of the html code, both redirecting and commands
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@97 a672b425-5310-4d7a-af5c-997e18724b81
2018-11-11 12:33:39 +00:00

61 lines
1.1 KiB
HTML

---
layout: page
category-page: scripts
category-title: Scripting
tags: redirect output input
author: Dario Rasic
title: Redirection
---
<br>
<!-- Output redirection text -->
<h2>Output as input</h2>
<p>To redirect a certain output of the command-line we have to use the symbol "&gt;".<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 "&gt;&gt;" symbols:</p>
<pre>
cat hello.txt
Sun
echo "Moon" >> hello.txt
cat hello.txt
Sun
Moon
</pre>
<!-- Input redirection text -->
<h2>Input as output</h2>
To redirect an input from a file for a command, the symbol "&lt;" is used.
<pre>
echo < $(cat hello.txt)
Sun
Moon
</pre>
This is particularly useful when chaining commands.
<br>
<!-- Chaining command text -->
<h2>Chaining</h2>
<br>
<h1>To be completed</h1>
</p>