In this lecture we are going to learn about readed action and piping.
Before we do that we need to know that every program we run on the command line has three data streams.
It has some that input which represents the data provided to program.
The stream is represented by number 0.
Then we have standard output which is very present in Dubai number one and it is basically what program
brings to us stream is standard and are represented by number two.
And it means a lot of messages de-program brains how to imagine those streams in more graphical way.
Here we see that the standard input stream provides some data into a program then the program for example
cat ping or US processes data.
And if there is no problem with processing data program provides output on standard outputs in other
device if program has some issue with processing input data it will provide output into standard error
string.
Now let's Jeg how detection works and we can check it on some examples.
We have here output of cat command which will basically display content of file 1.0 text.
So how we do the actual early detection we are using symbol greater than by specifying greater and symbol
we can detect output of cut command somewhere else.
In our case the file output from code that text but the stream is directed to that output from Cat file.
It is standard output or standard error or both of them.
Firstly Let's check another example because it is important.
Now if I tell you that both commands do the same.
Can you tell me what stream is re-elected in the first example.
It is standard output views before a greater than symbol number of specific string.
We are basically telling that direct output from that stream to somebody else.
And because in most cases it is redirected on a standard output.
You don't need to specify number one before a greater than symbol and it will do the same job for you.
Similarly if you want to redirect only standart at overstrain to some file we are using number two before
a greater than symbol.
We can also redirect both standard output and error streams to different files if you want to read it
at both standard and stream to same file.
We can do it easily by prepending ampersands and more before a greater than symbol.
In some cases we maybe want to read it as standard or stream to standard output stream and we can do
that using two greater than ampersands one in this example.
We are directing Stamm that output stream to file output from Qadar text and we also are directing standard
arrow stream to standard output stream which is is to the file output from Cadoudal text.
So that means that stream is directed also to that file output from cat got text when we are using gaitered
and symbol one had a direct link to a file we always sort of writing Godet file if that file does not
exist it will be created in some cases you might want to rather add some lines to a file instead of
completely rewrite it.
So for that you can use double grade then symbol.
We can also use redirection to provide the data to standard input.
Here we have examples of wc command which takes one argument Feitel dot text if you want to provide
file that text as a standard import.
We are using less than symbol.
So what is the difference between those two examples provided out.
What is the difference as of when we do that actually using less than symbol data are sent anonymously.
So we see only how many lines that file contains.
Now let's talk also about piping of what piping does is simple.
It is sending data from one program to another.
For example here we are sending output of the command to command that Brucey which will then print the
same output as using readied action.
But if you want to see the real power of piping look at the following example.
Here we have output of the command which you send to the program with parameter 5.
That means only first five lines will be printed.
Then this output of five lines is sent to program tail with parameter Swee which means only last sorry
lines of previous output are printed and then does.
So the lines output is sent to that Brucey command which will print number of lines.
In our case number Sorry So enough already.
Let's see this bad boy in action.