1
00:00:01,520 --> 00:00:06,620
In this lecture we are going to learn about readed action and piping.

2
00:00:07,140 --> 00:00:14,530
Before we do that we need to know that every program we run on the command line has three data streams.

3
00:00:15,640 --> 00:00:20,740
It has some that input which represents the data provided to program.

4
00:00:20,830 --> 00:00:24,870
The stream is represented by number 0.

5
00:00:24,880 --> 00:00:32,470
Then we have standard output which is very present in Dubai number one and it is basically what program

6
00:00:32,500 --> 00:00:38,990
brings to us stream is standard and are represented by number two.

7
00:00:39,090 --> 00:00:48,220
And it means a lot of messages de-program brains how to imagine those streams in more graphical way.

8
00:00:48,240 --> 00:00:55,320
Here we see that the standard input stream provides some data into a program then the program for example

9
00:00:55,320 --> 00:00:58,970
cat ping or US processes data.

10
00:00:59,100 --> 00:01:07,310
And if there is no problem with processing data program provides output on standard outputs in other

11
00:01:07,310 --> 00:01:14,190
device if program has some issue with processing input data it will provide output into standard error

12
00:01:14,220 --> 00:01:15,950
string.

13
00:01:16,530 --> 00:01:22,180
Now let's Jeg how detection works and we can check it on some examples.

14
00:01:23,560 --> 00:01:30,400
We have here output of cat command which will basically display content of file 1.0 text.

15
00:01:30,400 --> 00:01:38,980
So how we do the actual early detection we are using symbol greater than by specifying greater and symbol

16
00:01:39,190 --> 00:01:43,180
we can detect output of cut command somewhere else.

17
00:01:43,180 --> 00:01:52,180
In our case the file output from code that text but the stream is directed to that output from Cat file.

18
00:01:52,240 --> 00:01:57,040
It is standard output or standard error or both of them.

19
00:01:57,050 --> 00:02:02,290
Firstly Let's check another example because it is important.

20
00:02:02,380 --> 00:02:06,610
Now if I tell you that both commands do the same.

21
00:02:06,610 --> 00:02:11,280
Can you tell me what stream is re-elected in the first example.

22
00:02:12,200 --> 00:02:18,850
It is standard output views before a greater than symbol number of specific string.

23
00:02:18,930 --> 00:02:24,330
We are basically telling that direct output from that stream to somebody else.

24
00:02:24,680 --> 00:02:29,490
And because in most cases it is redirected on a standard output.

25
00:02:29,510 --> 00:02:37,120
You don't need to specify number one before a greater than symbol and it will do the same job for you.

26
00:02:37,640 --> 00:02:45,570
Similarly if you want to redirect only standart at overstrain to some file we are using number two before

27
00:02:45,580 --> 00:02:47,620
a greater than symbol.

28
00:02:47,750 --> 00:02:56,380
We can also redirect both standard output and error streams to different files if you want to read it

29
00:02:56,390 --> 00:02:59,970
at both standard and stream to same file.

30
00:02:59,990 --> 00:03:06,730
We can do it easily by prepending ampersands and more before a greater than symbol.

31
00:03:06,950 --> 00:03:13,850
In some cases we maybe want to read it as standard or stream to standard output stream and we can do

32
00:03:13,850 --> 00:03:19,950
that using two greater than ampersands one in this example.

33
00:03:19,970 --> 00:03:27,500
We are directing Stamm that output stream to file output from Qadar text and we also are directing standard

34
00:03:27,590 --> 00:03:34,300
arrow stream to standard output stream which is is to the file output from Cadoudal text.

35
00:03:34,520 --> 00:03:45,800
So that means that stream is directed also to that file output from cat got text when we are using gaitered

36
00:03:45,800 --> 00:03:52,690
and symbol one had a direct link to a file we always sort of writing Godet file if that file does not

37
00:03:52,750 --> 00:04:01,180
exist it will be created in some cases you might want to rather add some lines to a file instead of

38
00:04:01,180 --> 00:04:02,720
completely rewrite it.

39
00:04:02,770 --> 00:04:07,390
So for that you can use double grade then symbol.

40
00:04:07,840 --> 00:04:13,130
We can also use redirection to provide the data to standard input.

41
00:04:13,150 --> 00:04:21,100
Here we have examples of wc command which takes one argument Feitel dot text if you want to provide

42
00:04:21,100 --> 00:04:23,640
file that text as a standard import.

43
00:04:23,800 --> 00:04:26,690
We are using less than symbol.

44
00:04:26,830 --> 00:04:31,280
So what is the difference between those two examples provided out.

45
00:04:31,290 --> 00:04:39,590
What is the difference as of when we do that actually using less than symbol data are sent anonymously.

46
00:04:39,610 --> 00:04:44,770
So we see only how many lines that file contains.

47
00:04:44,780 --> 00:04:50,440
Now let's talk also about piping of what piping does is simple.

48
00:04:50,520 --> 00:04:55,240
It is sending data from one program to another.

49
00:04:55,320 --> 00:05:02,970
For example here we are sending output of the command to command that Brucey which will then print the

50
00:05:02,970 --> 00:05:05,960
same output as using readied action.

51
00:05:06,330 --> 00:05:12,360
But if you want to see the real power of piping look at the following example.

52
00:05:12,470 --> 00:05:19,530
Here we have output of the command which you send to the program with parameter 5.

53
00:05:19,560 --> 00:05:23,580
That means only first five lines will be printed.

54
00:05:23,580 --> 00:05:32,250
Then this output of five lines is sent to program tail with parameter Swee which means only last sorry

55
00:05:32,340 --> 00:05:37,530
lines of previous output are printed and then does.

56
00:05:37,570 --> 00:05:44,490
So the lines output is sent to that Brucey command which will print number of lines.

57
00:05:44,580 --> 00:05:49,980
In our case number Sorry So enough already.

58
00:05:50,090 --> 00:05:52,890
Let's see this bad boy in action.
