--- layout: page category-page: scripts category-title: Scripting tags: redirect output input author: Dario Rasic title: Redirection ---

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):

echo "Sun" > hello.txt
So if we print the content of the file in our command-line, the output will be the following:
cat hello.txt
Sun
If we want to append a certain output to an existing file, we just have to use ">>" symbols:

cat hello.txt
Sun
echo "Moon" >> hello.txt
cat hello.txt
Sun
Moon

Input as output

To redirect an input from a file for a command, the symbol "<" is used.
echo < $(cat hello.txt)
Sun
Moon
This is particularly useful when chaining commands.

Chaining


To be completed