From 3be0f51b1699cc41ceac6b180df4e8681abf5d73 Mon Sep 17 00:00:00 2001
From: rasicd This command print as output its entire argument on the command-line.
- To redirect a certain output of the command-line we have to use the symbol ">".
-Echo
-
+Echo
It could be used with variables, like in the following example:
@@ -23,7 +22,7 @@ this is an example
-Cat
+Cat
This command prints the content of a certain file as an output on the command-line.
@@ -38,7 +37,7 @@ pages Hello
-Grep
+Grep
This one behaves very similarly to the previus one, but in this case it prints only the lines matching a certain pattern.
In this we could imagine a certain text file "animals", which contains a list of animal-names.
diff --git a/site/pages/scripts/redirection.html b/site/pages/scripts/redirection.html
index e523aa3..0c05a16 100644
--- a/site/pages/scripts/redirection.html
+++ b/site/pages/scripts/redirection.html
@@ -7,9 +7,10 @@ author: Dario Rasic
title: Redirection
---
Output as input
-
+Output as input
+
+To redirect a certain output of the command-line we have to use the symbol ">".
In this case, we will use a file named hello.txt, in which we want to insert
a certain output ("Sun" in this case):
@@ -26,7 +27,7 @@ cat hello.txt
If we want to append a certain output to an existing file,
-we just have to use ">>" symbols:
cat hello.txt @@ -39,7 +40,7 @@ cat hello.txtInput as output
- +
To redirect an input from a file for a command, the symbol "<" is used.@@ -47,14 +48,34 @@ echo < $(cat hello.txt) Sun Moon- -This is particularly useful when chaining commands. - +This is particularly useful when chaining commands.
- -Chaining
+Chaining (or Piping)
-To be completed
+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. + ++cat hello.txt | grep Mo +Moon ++ + +Simple Example
+
+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.
+ +We want to sort the animals whose name begins with letter "d" from the file animals.txt and put it into d_animals.txt.
+ ++grep d < animals.txt > d_animals.txt ++
+cat d_animals.txt +Deer +Dog +Dolphin +... +