You can use the `>` character to redirect a flux toward a file. The following command make a copy of your `.bashrc` files.
You can use the `>` character to redirect a flux toward a file. The following command makes a copy of your `.bashrc` files.
```sh
```sh
cat .bashrc > my_bashrc
cat .bashrc > my_bashrc
...
@@ -82,11 +82,11 @@ cal -N 2 > my_cal
...
@@ -82,11 +82,11 @@ cal -N 2 > my_cal
What is the content of `my_cal` what happened ?
What is the content of `my_cal` what happened ?
The `>` command can have an argument, the syntax to redirect **stdout** to a file is `1>` it's also the default option (equivalent to `>`). Here the `-N` option doesn't exists, `cal` throws an error. Errors are sent to **stderr** which have the number 2.
The `>` command can have an argument, the syntax to redirect **stdout** to a file is `1>` it's also the default option (equivalent to `>`). Here the `-N` option doesn't exist, `cal` throws an error. Errors are sent to **stderr** which have the number 2.
Save the error message in `my_cal` and check the results with `less`.
Save the error message in `my_cal` and check the results with `less`.
We have seen tha `>` overwrite the content of the file. Try the following commands:
We have seen that `>` overwrite the content of the file. Try the following commands:
```sh
```sh
cal 2020 > my_cal
cal 2020 > my_cal
...
@@ -96,7 +96,7 @@ cal -N 2 2>> my_cal
...
@@ -96,7 +96,7 @@ cal -N 2 2>> my_cal
Check the results with the command `less`.
Check the results with the command `less`.
The command `>` send the stream from the left to the file on the right. Try the following:
The command `>` sends the stream from the left to the file on the right. Try the following:
```sh
```sh
cat < my_cal
cat < my_cal
...
@@ -114,7 +114,7 @@ Type some text and type `EOF` on a new line. `EOF` stand for **e**nd **o**f **f*
...
@@ -114,7 +114,7 @@ Type some text and type `EOF` on a new line. `EOF` stand for **e**nd **o**f **f*
What happened ? Can you check the content of `my_notes` ? How would you modify this command to add new notes?
What happened ? Can you check the content of `my_notes` ? How would you modify this command to add new notes?
Finaly you can redirect a stream toward another stream with the following syntax:
Finally, you can redirect a stream toward another stream with the following syntax:
```sh
```sh
cal -N2 2&> my_redirection
cal -N2 2&> my_redirection
...
@@ -155,7 +155,7 @@ Analyze the following command, what would it do ?
...
@@ -155,7 +155,7 @@ Analyze the following command, what would it do ?
wget -q -O - http://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.fa.gz | gzip -dc | less
wget -q -O - http://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.fa.gz | gzip -dc | less
```
```
Remember that most Unix command process input and output line by line. Which means that you can process huge dataset without intermediate files or huge RAM capacity.
Remember that most Unix command process input and output line by line. Which means that you can process huge datasets without intermediate files or huge RAM capacity.