Now let's start with buying and redirection.
Now, if a program run from a command line has three data streams connected to it.
The first thing, which is STD and STD out as CD error so as to the end, which is the standard input.
This is data fed into the program.
So this is as an input standard output, which is STD out to output from the program.
This is default to terminal.
And we have the STD error, which is a standard error.
This is the error messages.
And by default it is to it is going to terminate.
So for the pipeline or by Bing, we will use shift backslash.
Which is this one, the vertical line for redirection we will use either greater than or less than OC.
Now let's have more details about it.
So for example, I will use the LS command.
Now you can see that the last command it will show us something like that OC.
So if I want to have this to be.
Record it to a file.
So the output of the LZ to be recorded to a file, I will use the redirection.
So unless the space shift greater than which means it will be the output from here, it will be considered
in both to what, for example, test the text, press enter.
Now you can see the output hasn't been written to the terminal, but other than that it has been written
here.
Now we have to show no such a thing.
How to know I would use the acat command or cat.
This is the concatenation or alternation cat.
So cat dist dot text and it will show us what has been recorded as you can see.
The output of the LZ command OC the same thing if I type e co double quotation.
Hi there.
And let's put it inside this to the text, for example.
Now if I type cat fist to the text, it will show us how they're OC just as we want.
Now imagine I have this file and I don't want to write.
Overwrite it over and over.
I want hi there.
And I want to put more commands to it so I can put the same command as you can see.
Hi there.
For the second time, for example, and I will use double greater than this time.
So this means that add the echo or the output of this command, which is high there for the second time
and appended to the test the text this to file.
Now here, get again.
Test to the text.
And you can see that.
Hi there.
For the second time, you can see that it has backslash n or a new line.
Because by default the echo command it will bring backslash n it is considered backslash n and backslash
n means a new line.
Now we can choose another thing which is using dash e to skip the thing.
So this is well, not print.
This is to put backslash whatever thing here and we can use the n command so n e and do not print backslash
n so it will not print a new line, by the way.
How did I know about it?
Again, just open it.
And here you can see all the options from the manual page here and do not output the trailing new line
which is backslash n e to enable interpretation of backslash skips like backslash e backslash, whatever.
Well, I'm assuming that you are familiar with these.
If you are not, you can read more about it.
Or you can ask me.
No problem.
Okay.
Now let's quit from here.
Now, this is for the greater than the redirection.
Now, what if I want to redirect from a file?
So the greater than as we saw that it will bring the output of the RLS and to put it to the text and
with using double or greater then which means appending.
Now if I want to read from a file, so for example, I will use the command wc.
Now WC you can see this is to print new line word and by its count for each file.
So this is for word count.
It stands for word count.
So if I type word count.
And the twist to the text.
It will show us like the following that this text file has to.
Lines eight and 38 letters.
How did I know that?
Just the man, W.S. And here you can see it will print a new line.
What, however, how much line we have?
How much word and how much byte counts?
Or, by the way, the character itself considered to be a byte.
So byte here means that character.
Okay.
And for this, we can use more options like dash C for the character, dash M for the cars dash and
how many lines and whatever the value for words.
So if I type w see dash w for word and test to the text, this will show us eight word inside the character.
So if I get here, you can see that one, two, three, four, five, six, seven, eight.
As you can see, eight word OC.
Cool.
So far so good.
Now we learned what is w see?
Now what is the redirection here?
All right, so let's clear the screen first.
Now w c again, dash w now this time, as you can see, we put for the w c command a file to read from
right.
Now what if I want to read from a specific file using the redirection?
Not like that.
So I can use the list then, which means that this wc command needs an input and get that input from
what?
File from text to the text.
And it will show us again the same thing.
By the way, if you notice we have a different output because this is using the redirection.
But here it.
Brent the eight character or eight word and the name of the file.
So you can see that the output is different somehow.
Okay.
Now, what if I want to redirect the STD error?
So clear the screen.
Now, if I type this command, you can see that it will show us command not found because this is just
a arbitrary example or arbitrary command not found in very light.
Now, what if I want to to see if it is not found?
Please don't show the error on the terminal.
For that, we will use something called redirection.
The STD error.
So to.
Which is.
See the error, by the way.
Zero.
Consider the HDD in but one consider to the HDD.
Output and to consider the STD or the standard.
Okay.
Now, I knew there is a lot of information here, but just follow me.
So too.
Without any spaces.
Redirection to the slash dev.
Slash none.
Now here is the final.
This is just another pointer.
It will point to nothing.
So run this command and the error, which is this one.
Go and let it go to be inside here.
Dave NULL Which means don't print the error here, but it's there and the null here, which is just
avoid nothing there.
So press enter.
You can see that this time the command that the command not found here error hasn't been output to the
terminal because we redirected the standard error to B to the additional, which is the void of the
system.
Now what if I run again, get test three.
The text, by the way, it is the three.
The text is not found.
As you can see, no such file or directory.
Now, how should I print this?
And if there is no such file, I don't want to to be automated, to be printed to the terminal.
How should I do that?
Yes, you are correct, as we learned previously.
So cut this three to text.
It is not found if it is not found, but to or the standard error to be inside if null.
And you can see you guessed it right.
And it is working correctly.
Okay, now enough with the right direction.
We learned the right direction greater than w greater than and less than.
And we learned how to redirect the standard error to the null.
So the error will not be printed to the terminal.
Now it's time to talk about piping.
Now, as we learned, piping is using the vertical line shift, backslash, OC or whatever it is in
your keyboard.
Now, for example, if I cut.
This to the text.
You can see that it will start showing.
Hi there.
For the second time, as we learned now, what if I want to count the number of words for this file?
I would use pipe or as we learned, using the WC command.
Using the redirection or w c dash W for the file itself.
But there is another way to do it, by the way, using the by lining.
So cut this to the text and the output with the pipeline is the output of this command will be considered
in both for this command.
So this to the text and the output of this, which is the high there.
Hi there for the second time will be input for the another command which is w c dash w oc.
Now if I do that press into us it is working correctly.
So the output here.
Consider to be in what for this command.
Okay, so this is what by blind means.
By the way, we can watch redirection again and again using by blinding.
So cut this to the text.
And by blinding and the output will be considered input for this.
And again put this to be.
Result the text, for example.
And if I type as you can see a result the text here get it to see what is inside it.
Yeah it is working 100%.
All right, cool.
So far, so good.
Now again, I recommend you to practice with me.
And practice what you have learned on whatever values.
I will provide more exercises.
And assignment for a simple exercises.
Just to practice what we have learned here.