1 00:00:07,110 --> 00:00:08,280 - All right to start with, 2 00:00:08,280 --> 00:00:10,410 we need to delete the fifth line. 3 00:00:10,410 --> 00:00:15,410 So, let me first you still minus five all users. 4 00:00:17,130 --> 00:00:19,050 I like simple solutions 5 00:00:19,050 --> 00:00:22,230 and here we can see the simple solution. 6 00:00:22,230 --> 00:00:24,210 Oops. This is the last five line. 7 00:00:24,210 --> 00:00:26,670 I don't wanna see the last five lines. 8 00:00:26,670 --> 00:00:28,380 I want to see the first five lines. 9 00:00:28,380 --> 00:00:30,870 So that will be Bob Belle. 10 00:00:30,870 --> 00:00:35,255 So next I'm using SED, minus I to interactively write 11 00:00:35,255 --> 00:00:37,500 to the target file minus E 12 00:00:37,500 --> 00:00:42,450 for the edit command, five D to delete line number five 13 00:00:42,450 --> 00:00:44,010 from the file users. 14 00:00:44,010 --> 00:00:45,780 And if I use my hat again 15 00:00:45,780 --> 00:00:50,340 then we can see that Bob Belle has been deleted. 16 00:00:50,340 --> 00:00:51,270 So what is next? 17 00:00:51,270 --> 00:00:54,150 Next is use Bob, in a pipe to filter the first column 18 00:00:54,150 --> 00:00:58,020 out of the results of the command PS AUX. 19 00:00:58,020 --> 00:01:00,090 In order to understand that we need 20 00:01:00,090 --> 00:01:01,830 to have a look at PS AUX. 21 00:01:01,830 --> 00:01:02,670 There we go. 22 00:01:02,670 --> 00:01:06,270 These columns are, are formatted pretty nicely. 23 00:01:06,270 --> 00:01:11,270 So PS AUX pipe AWK, let's just check 24 00:01:11,700 --> 00:01:15,540 print dollar one and see what it is doing. 25 00:01:15,540 --> 00:01:17,460 That's pretty successful. 26 00:01:17,460 --> 00:01:20,790 Many commands that are about filtering are using spaces 27 00:01:20,790 --> 00:01:23,640 as a default field separator. 28 00:01:23,640 --> 00:01:25,770 You only use another field separator. 29 00:01:25,770 --> 00:01:27,780 You can specify that, depending 30 00:01:27,780 --> 00:01:30,510 on how to use the command minus 31 00:01:30,510 --> 00:01:32,460 uppercase F for AWK that is. 32 00:01:32,460 --> 00:01:35,612 But in this case, it was really simple because it's a space 33 00:01:35,612 --> 00:01:39,390 the space, which is used as a separator. 34 00:01:39,390 --> 00:01:41,010 The third task was to use, GREP 35 00:01:41,010 --> 00:01:42,480 to show the names of all files 36 00:01:42,480 --> 00:01:43,740 in (indistinct) that have lines 37 00:01:43,740 --> 00:01:46,650 starting with the text route. 38 00:01:46,650 --> 00:01:50,427 So I need SUDO for complete elite access. 39 00:01:50,427 --> 00:01:51,260 Grep. 40 00:01:51,260 --> 00:01:52,380 what am I going to GREP? 41 00:01:52,380 --> 00:01:55,560 Well, lines starting with that's carrot. 42 00:01:55,560 --> 00:01:59,583 So lines starting with ROOT in ETC star. 43 00:02:02,559 --> 00:02:04,830 Oh, and I need a GREP option as well. 44 00:02:04,830 --> 00:02:06,540 GREP minus L. 45 00:02:06,540 --> 00:02:08,670 Hey, about the position of the option. 46 00:02:08,670 --> 00:02:10,770 I know Linux is flexible. 47 00:02:10,770 --> 00:02:12,150 It should work putting the option 48 00:02:12,150 --> 00:02:14,880 at the, at the end of the line as well. 49 00:02:14,880 --> 00:02:17,790 But if it's getting more complex, like in GREP where 50 00:02:17,790 --> 00:02:20,010 you are using a regular expression. 51 00:02:20,010 --> 00:02:22,440 Personally, I like putting the options directly 52 00:02:22,440 --> 00:02:26,010 after the GREP command, then you do your regular expression 53 00:02:26,010 --> 00:02:29,940 and then you do your file globbing pattern that makes it 54 00:02:29,940 --> 00:02:33,249 easier for yourself to understand what is going on. 55 00:02:33,249 --> 00:02:38,249 And shall we also, as a precaution, use two greater than 56 00:02:38,490 --> 00:02:42,450 DEV, NULL so that we don't see any error messages at all. 57 00:02:42,450 --> 00:02:43,283 And there we go. 58 00:02:43,283 --> 00:02:45,900 These are the lines that we were looking for. 59 00:02:45,900 --> 00:02:48,750 And if you want to verify that really, that is the case 60 00:02:48,750 --> 00:02:52,170 just remove the minus L and you can see behind the name 61 00:02:52,170 --> 00:02:55,953 of the file, how exactly the line was starting. 62 00:02:56,790 --> 00:02:59,040 Okay, the next assignment is to 63 00:02:59,040 --> 00:03:01,740 show all lines from all files 64 00:03:01,740 --> 00:03:04,920 and users that have at least three letters N. 65 00:03:04,920 --> 00:03:06,240 How are we going to do that? 66 00:03:06,240 --> 00:03:11,240 Well, by using GREP with this repetition operator 67 00:03:12,000 --> 00:03:16,350 and the repetition operator is going to be N followed 68 00:03:16,350 --> 00:03:21,350 by slash, curly brace, three slash, curly brace, 69 00:03:23,070 --> 00:03:24,930 single quote, users. 70 00:03:24,930 --> 00:03:26,040 And there we go. 71 00:03:26,040 --> 00:03:28,320 That's a match for three letters N. 72 00:03:28,320 --> 00:03:30,780 And finally, we use GREP to find all files 73 00:03:30,780 --> 00:03:32,160 that contain string, and I 74 00:03:32,160 --> 00:03:34,270 at the end of the line, that's an easy one. 75 00:03:34,270 --> 00:03:39,270 SUDO, GREP, minus R, ANNA dollar. 76 00:03:43,590 --> 00:03:45,480 And you know what, 77 00:03:45,480 --> 00:03:47,220 let's just do it on the current directory. 78 00:03:47,220 --> 00:03:48,840 You get the idea that you can do this 79 00:03:48,840 --> 00:03:51,480 on the entire route file system as well. 80 00:03:51,480 --> 00:03:54,450 And we don't, of course we don't 81 00:03:54,450 --> 00:03:56,940 because I just changed my users file. 82 00:03:56,940 --> 00:04:01,940 Okay, so I need to, to use ECHO, HELLO, ANNA, 83 00:04:04,110 --> 00:04:06,660 greater than greater than to users. 84 00:04:06,660 --> 00:04:07,890 We have seen users, 85 00:04:07,890 --> 00:04:09,690 we have seen single greater then, 86 00:04:09,690 --> 00:04:11,460 which is redirecting the output. 87 00:04:11,460 --> 00:04:13,080 This is a double greater then 88 00:04:13,080 --> 00:04:16,500 which is bending the line to the end of the file. 89 00:04:16,500 --> 00:04:19,705 And now if I read this again and let me, 90 00:04:19,705 --> 00:04:22,860 let me get rid of the error messages. 91 00:04:22,860 --> 00:04:25,410 Then we can see that users is a match. 92 00:04:25,410 --> 00:04:28,743 And that is what you needed to do for this lab.