Hello everyone.
In this demo, I'm going to show you how to use the pipe command and the grep command.
First, let's start with the pipe command.
The pipe command helps to use two or more commands as one command in order to retrieve and obtain one
output.
Let's show some examples how to use commands with pipe command.
I'm going to type first the the command cat slash Etsy slash bast WD space, then the pipe, then the
second command is list.
As we can see here, this is the first command.
Then the pipe, then list hit enter.
And I'm going to do another example here, the cat slash Etsy slash shadow, then space pipe, then
more hit enter.
As we can see here, we get one output.
I'm going to do another example here, slash bin, then pipe and and I'm going to use the command wc
wc print new line world and pipe counts for each file.
And also I'm going to use the option dash L in order to get the number of lines hit.
Enter.
As we can see here, we get one output.
Let's do another example here for the file month.
So the first command is cat month.
That takes then pipe.
In this case I'm going to use the command WC then dash C in order to get the number of characters I
hit enter.
As you can see here, we get one output I'm going to do this time cat for this file f dot txt and a
pipe then wc dash w so the dash w this option gets the number of volts and hit enter.
Now let's move on to another example.
I'm going to show the content of the F2 dot txt.
As you can see over here.
Now I'm going to use the hit command dash n.
The number means that I would like to show the first three lines and the file f2 dot txt and also at
the same time I would like to use the pipe then tell dash n the number one.
So what I'm going to tell the system since we have the pipe here, I'm not going to show the first three
lines.
I'm going to show the last line.
Here, for example.
Here.
The first command shows the first three lines, one, 20 and two, but with the tail dash n one.
I'm going to show only the last line here.
I hit enter.
As you can see here, we got the last line if I'm going to change the number here to two.
So let's take the first command here.
I'm going to show the first three lines.
However, with the pipe tell dash n, then the number two.
It means that I would like to show the last two lines and I hit enter.
As we can see here, we get the last two lines here.
Now let's move on to the next command.
The Grip Command.
Grip.
Command prints, lines matching a pattern.
For example, grip.
Then know log n for the file ATC slash base deputy.
Perfect.
I'm not going to use the pipe here.
I just want to get the outcome first.
Then we're going to use the pipe to compare the outcome between this outcome and the next outcome.
So I'm going to hit enter.
As we can see here, we get a log outcome, as we can see here, because we didn't use the pipe with
another command.
So I'm going to use the same command here.
Then space pipe.
WC then dash l in order to get the number of lines I hit enter.
As we can see here, we get totally different output are going to do another example also here cat number.
First I'm going to run the the command.
I'm not going to use the pipe command here.
Hit enter.
As we can see here, we get the numbers from 1 to 20.
Now, I'm going to use the pipe command.
Then I'm going to use sort.
And I hit enter, as we can see over here.
We sorted the the the content of the file based on, on the number.
It starts from one, then two and so on.
If I will do cat.
A month.
I'm going to do this example, the month then and the pipe.
Then I would like to grab a and I hit enter.
As we can see over here, we got the outcomes that has the what?
The letter A.
If I will do the same thing but to a different letter grip P for example.
So with the P, I'm going to get outcome with letter B, if I will use the head command head minus N,
then number five, it means that I would like to show the first five lines in the file math dot txt,
then the pipe sort.
Hit enter.
So we get the first five lines.
Then with the pipe, we sort them based on the alphabets.
We'll do the last example here.
Tel minus N, then number three, I'm going to do it for the month, the txt file, then the pipe,
then sort.
Command dash r the recursive then hit enter.
As we can see here, we get an outcome based on.
The reverse way for the sort command.
Thus concludes our session.
Thank you and see you in the next lesson.