1 00:00:00,320 --> 00:00:01,310 Hello everyone. 2 00:00:01,310 --> 00:00:06,410 In this demo, I'm going to show you how to use the pipe command and the grep command. 3 00:00:06,500 --> 00:00:09,170 First, let's start with the pipe command. 4 00:00:09,320 --> 00:00:17,810 The pipe command helps to use two or more commands as one command in order to retrieve and obtain one 5 00:00:17,810 --> 00:00:18,650 output. 6 00:00:19,040 --> 00:00:23,900 Let's show some examples how to use commands with pipe command. 7 00:00:24,440 --> 00:00:35,030 I'm going to type first the the command cat slash Etsy slash bast WD space, then the pipe, then the 8 00:00:35,030 --> 00:00:36,230 second command is list. 9 00:00:36,230 --> 00:00:38,960 As we can see here, this is the first command. 10 00:00:39,200 --> 00:00:42,650 Then the pipe, then list hit enter. 11 00:00:44,870 --> 00:00:53,780 And I'm going to do another example here, the cat slash Etsy slash shadow, then space pipe, then 12 00:00:53,780 --> 00:00:55,520 more hit enter. 13 00:00:55,520 --> 00:00:58,610 As we can see here, we get one output. 14 00:00:59,240 --> 00:01:08,790 I'm going to do another example here, slash bin, then pipe and and I'm going to use the command wc 15 00:01:08,940 --> 00:01:14,190 wc print new line world and pipe counts for each file. 16 00:01:15,030 --> 00:01:22,890 And also I'm going to use the option dash L in order to get the number of lines hit. 17 00:01:22,890 --> 00:01:23,370 Enter. 18 00:01:23,370 --> 00:01:25,710 As we can see here, we get one output. 19 00:01:26,250 --> 00:01:30,270 Let's do another example here for the file month. 20 00:01:30,450 --> 00:01:32,640 So the first command is cat month. 21 00:01:32,640 --> 00:01:34,170 That takes then pipe. 22 00:01:34,560 --> 00:01:42,120 In this case I'm going to use the command WC then dash C in order to get the number of characters I 23 00:01:42,150 --> 00:01:43,020 hit enter. 24 00:01:44,240 --> 00:01:52,940 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 25 00:01:52,940 --> 00:02:03,950 pipe then wc dash w so the dash w this option gets the number of volts and hit enter. 26 00:02:06,020 --> 00:02:08,300 Now let's move on to another example. 27 00:02:08,660 --> 00:02:11,870 I'm going to show the content of the F2 dot txt. 28 00:02:12,050 --> 00:02:13,450 As you can see over here. 29 00:02:13,460 --> 00:02:18,590 Now I'm going to use the hit command dash n. 30 00:02:18,620 --> 00:02:28,280 The number means that I would like to show the first three lines and the file f2 dot txt and also at 31 00:02:28,280 --> 00:02:36,050 the same time I would like to use the pipe then tell dash n the number one. 32 00:02:36,050 --> 00:02:43,650 So what I'm going to tell the system since we have the pipe here, I'm not going to show the first three 33 00:02:43,650 --> 00:02:44,190 lines. 34 00:02:44,370 --> 00:02:48,270 I'm going to show the last line. 35 00:02:49,920 --> 00:02:51,120 Here, for example. 36 00:02:51,120 --> 00:02:51,540 Here. 37 00:02:52,430 --> 00:03:00,680 The first command shows the first three lines, one, 20 and two, but with the tail dash n one. 38 00:03:01,540 --> 00:03:04,810 I'm going to show only the last line here. 39 00:03:04,810 --> 00:03:05,680 I hit enter. 40 00:03:05,890 --> 00:03:11,260 As you can see here, we got the last line if I'm going to change the number here to two. 41 00:03:12,280 --> 00:03:15,370 So let's take the first command here. 42 00:03:16,000 --> 00:03:17,710 I'm going to show the first three lines. 43 00:03:17,710 --> 00:03:21,640 However, with the pipe tell dash n, then the number two. 44 00:03:21,670 --> 00:03:26,380 It means that I would like to show the last two lines and I hit enter. 45 00:03:26,500 --> 00:03:29,950 As we can see here, we get the last two lines here. 46 00:03:31,420 --> 00:03:34,750 Now let's move on to the next command. 47 00:03:34,780 --> 00:03:36,040 The Grip Command. 48 00:03:36,070 --> 00:03:36,550 Grip. 49 00:03:36,550 --> 00:03:39,010 Command prints, lines matching a pattern. 50 00:03:39,040 --> 00:03:40,900 For example, grip. 51 00:03:41,110 --> 00:03:48,310 Then know log n for the file ATC slash base deputy. 52 00:03:49,030 --> 00:03:49,720 Perfect. 53 00:03:49,870 --> 00:03:51,760 I'm not going to use the pipe here. 54 00:03:51,760 --> 00:03:53,800 I just want to get the outcome first. 55 00:03:53,830 --> 00:03:59,470 Then we're going to use the pipe to compare the outcome between this outcome and the next outcome. 56 00:03:59,470 --> 00:04:00,700 So I'm going to hit enter. 57 00:04:00,970 --> 00:04:08,410 As we can see here, we get a log outcome, as we can see here, because we didn't use the pipe with 58 00:04:08,410 --> 00:04:10,360 another command. 59 00:04:10,390 --> 00:04:13,150 So I'm going to use the same command here. 60 00:04:14,920 --> 00:04:16,750 Then space pipe. 61 00:04:16,750 --> 00:04:22,330 WC then dash l in order to get the number of lines I hit enter. 62 00:04:22,360 --> 00:04:32,590 As we can see here, we get totally different output are going to do another example also here cat number. 63 00:04:33,540 --> 00:04:36,180 First I'm going to run the the command. 64 00:04:36,180 --> 00:04:38,520 I'm not going to use the pipe command here. 65 00:04:38,700 --> 00:04:39,380 Hit enter. 66 00:04:39,390 --> 00:04:42,630 As we can see here, we get the numbers from 1 to 20. 67 00:04:42,660 --> 00:04:45,750 Now, I'm going to use the pipe command. 68 00:04:46,170 --> 00:04:48,870 Then I'm going to use sort. 69 00:04:50,410 --> 00:04:54,160 And I hit enter, as we can see over here. 70 00:04:54,640 --> 00:05:00,780 We sorted the the the content of the file based on, on the number. 71 00:05:00,790 --> 00:05:04,330 It starts from one, then two and so on. 72 00:05:04,510 --> 00:05:07,270 If I will do cat. 73 00:05:08,240 --> 00:05:09,560 A month. 74 00:05:10,100 --> 00:05:13,190 I'm going to do this example, the month then and the pipe. 75 00:05:13,310 --> 00:05:17,660 Then I would like to grab a and I hit enter. 76 00:05:18,170 --> 00:05:24,980 As we can see over here, we got the outcomes that has the what? 77 00:05:26,150 --> 00:05:27,050 The letter A. 78 00:05:28,140 --> 00:05:32,820 If I will do the same thing but to a different letter grip P for example. 79 00:05:32,820 --> 00:05:44,310 So with the P, I'm going to get outcome with letter B, if I will use the head command head minus N, 80 00:05:44,340 --> 00:05:53,490 then number five, it means that I would like to show the first five lines in the file math dot txt, 81 00:05:53,550 --> 00:05:55,770 then the pipe sort. 82 00:05:57,150 --> 00:05:57,900 Hit enter. 83 00:05:58,410 --> 00:06:02,570 So we get the first five lines. 84 00:06:02,580 --> 00:06:06,390 Then with the pipe, we sort them based on the alphabets. 85 00:06:07,200 --> 00:06:08,850 We'll do the last example here. 86 00:06:08,880 --> 00:06:19,890 Tel minus N, then number three, I'm going to do it for the month, the txt file, then the pipe, 87 00:06:19,920 --> 00:06:21,300 then sort. 88 00:06:22,780 --> 00:06:27,100 Command dash r the recursive then hit enter. 89 00:06:27,130 --> 00:06:32,680 As we can see here, we get an outcome based on. 90 00:06:33,430 --> 00:06:36,880 The reverse way for the sort command. 91 00:06:37,480 --> 00:06:39,190 Thus concludes our session. 92 00:06:39,220 --> 00:06:41,560 Thank you and see you in the next lesson.