finished the redirection file, with piping and example

git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@154 a672b425-5310-4d7a-af5c-997e18724b81
This commit is contained in:
rasicd 2018-11-12 19:14:49 +00:00
parent 2b3e9fa689
commit 3be0f51b16
2 changed files with 35 additions and 15 deletions

View File

@ -6,10 +6,9 @@ tags: command base echo cat grep
author: Dario Rasic
title: Script Base Commands
---
<br>
<!-- Echo command text -->
<h2>Echo</h2>
<h3>Echo</h3>
<p>This command print as output its entire argument on the command-line.<br>
It could be used with variables, like in the following example:<br>
@ -23,7 +22,7 @@ this is an example
<!-- Cat command text -->
<h2>Cat</h2>
<h3>Cat</h3>
This command prints the content of a certain file as an output on the command-line.<br>
@ -38,7 +37,7 @@ pages Hello
<!-- Grep command text -->
<h2>Grep</h2>
<h3>Grep</h3>
This one behaves very similarly to the previus one, but in this case it prints only the lines matching a certain pattern.<br>
In this we could imagine a certain text file "animals", which contains a list of animal-names.

View File

@ -7,9 +7,10 @@ author: Dario Rasic
title: Redirection
---
<p>
<h3>Output as input</h3>
<p>To redirect a certain output of the command-line we have to use the symbol "&gt;".<br>
<h3>Output as input</h3>
<br>
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>
@ -26,7 +27,7 @@ cat hello.txt
</pre>
If we want to append a certain output to an existing file,
we just have to use "&gt;&gt;" symbols:</p>
we just have to use "&gt;&gt;" symbols:
<pre>
cat hello.txt
@ -39,7 +40,7 @@ cat hello.txt
<!-- Input redirection text -->
<h3>Input as output</h3>
<br>
To redirect an input from a file for a command, the symbol "&lt;" is used.
<pre>
@ -47,14 +48,34 @@ echo < $(cat hello.txt)
Sun
Moon
</pre>
This is particularly useful when chaining commands.
<p>This is particularly useful when chaining commands.</p>
<br>
<!-- Chaining command text -->
<h3>Chaining</h3>
<h3>Chaining (or Piping)</h3>
<br>
<h1>To be completed</h1>
Chaining, also called Piping because it works with the pipe symbol "|", takes the output of a certain command-line and feeds it to another command in a direct way.
<!-- Table for the example of the piping command -->
<pre>
cat hello.txt | grep Mo
Moon
</pre>
<!-- A simple example -->
<h3>Simple Example</h3>
<br>
Now let's say that we want to combine those commands in a more complex operation. Let's say we want to take some contents from a certain file and put it into another file.<br>
We want to sort the animals whose name begins with letter "d" from the file <i>animals.txt</i> and put it into <i>d_animals.txt</i>.<br>
<pre>
grep d < animals.txt > d_animals.txt
<br>
cat d_animals.txt
Deer
Dog
Dolphin
...
</pre>
</p>