1 00:00:00,200 --> 00:00:01,130 Hello everyone. 2 00:00:01,130 --> 00:00:05,960 In this demo, I'm going to show you how to use the find command. 3 00:00:06,320 --> 00:00:10,700 Find command searches for lists, files and directories. 4 00:00:11,120 --> 00:00:14,090 I also can use conditions with find command. 5 00:00:14,760 --> 00:00:21,990 For example, I can use names, file type size users, groups, permissions and so on. 6 00:00:22,080 --> 00:00:26,070 Let's apply some examples to show how to use the find command. 7 00:00:26,220 --> 00:00:27,900 First, I'm going to type find. 8 00:00:28,080 --> 00:00:33,610 Then I would like to type from where to start the search. 9 00:00:33,630 --> 00:00:41,550 So in this case I would like to type dot, which means I would like to start the search from this current 10 00:00:41,550 --> 00:00:42,540 working directory. 11 00:00:42,540 --> 00:00:45,600 So the current working directory is the slash route. 12 00:00:45,690 --> 00:00:47,970 Then type. 13 00:00:48,510 --> 00:00:55,500 That's the type that like the type either files or directories that I would like to to do the search. 14 00:00:55,530 --> 00:01:00,180 So in this example, I would like to do the search for files. 15 00:01:00,210 --> 00:01:01,350 Then I hit enter. 16 00:01:01,770 --> 00:01:08,040 As you can see here, we get all the files under this current working directory. 17 00:01:09,870 --> 00:01:15,300 If I would like to do another example, same thing I will do this time under Slash home. 18 00:01:15,420 --> 00:01:19,550 So I would like to start the search from slash home. 19 00:01:19,560 --> 00:01:25,230 Then the type directory hit enter. 20 00:01:25,230 --> 00:01:29,970 So as we can see here, we got all the directories under the slash home. 21 00:01:31,500 --> 00:01:40,800 If I would like to find all the text files using the option dash name. 22 00:01:40,800 --> 00:01:43,020 So let's do that. 23 00:01:43,170 --> 00:01:50,640 I'm going to do the search from the current working directory, then the name, then the name. 24 00:01:50,640 --> 00:02:00,090 I would like to mention what exactly I'm going to search, so I'm going to search for the dot txt. 25 00:02:00,090 --> 00:02:05,400 So I'm going to as we can see here, I'm going to look for all the names. 26 00:02:05,400 --> 00:02:11,640 It doesn't matter uppercase lowercase because we wrote here the star. 27 00:02:12,700 --> 00:02:14,460 Then that d t. 28 00:02:14,920 --> 00:02:21,490 So this is the extension that I would like to look for all the files that has the extension txt. 29 00:02:21,670 --> 00:02:29,920 As you can see here I have to type the star dot txt under quotation mark. 30 00:02:29,950 --> 00:02:31,210 Then I hit enter. 31 00:02:31,840 --> 00:02:35,260 As we can see here, we got all the files. 32 00:02:35,260 --> 00:02:35,920 It doesn't matter. 33 00:02:35,920 --> 00:02:43,810 We didn't in this case we didn't mention the type because we already said that we would like to get 34 00:02:43,810 --> 00:02:50,230 all the files or the text files under the current working directory. 35 00:02:51,220 --> 00:02:58,500 If I would like to do the ignorecase, let's see if we do have for example, we don't. 36 00:02:58,510 --> 00:03:02,410 I'm going to first I'm going to create two directories. 37 00:03:02,410 --> 00:03:05,740 So as we can see here, it's lowercase. 38 00:03:06,040 --> 00:03:13,420 Then here I'm going to do this uppercase and I hit enter. 39 00:03:13,420 --> 00:03:18,010 As you can see here, we have two directories. 40 00:03:18,490 --> 00:03:25,960 Now, if I would like to do the search in this current working directory and. 41 00:03:26,700 --> 00:03:29,240 Dash name then. 42 00:03:29,270 --> 00:03:29,740 Dir. 43 00:03:30,080 --> 00:03:31,110 Dir. 44 00:03:32,110 --> 00:03:34,390 And we will hit enter. 45 00:03:34,390 --> 00:03:37,390 So as we can see here, we got one output. 46 00:03:37,420 --> 00:03:47,080 However, if I would do the dash I name, so I name means that it's ignoring case so it's going to ignore 47 00:03:47,080 --> 00:03:50,230 either uppercase or lowercase. 48 00:03:50,230 --> 00:03:52,240 I hit enter as we can see here. 49 00:03:52,240 --> 00:03:53,410 We got what? 50 00:03:54,840 --> 00:03:56,640 Two outcomes. 51 00:03:56,640 --> 00:04:00,810 So because we added the I here, so it is the ignoring case. 52 00:04:00,900 --> 00:04:05,160 So it doesn't matter if it's uppercase or lowercase. 53 00:04:05,340 --> 00:04:13,890 Now if I would like to use the dash delete to delete this directory. 54 00:04:13,890 --> 00:04:16,589 So first I'm going to find. 55 00:04:16,829 --> 00:04:22,530 Dot the current working directory I name before I'm going to do that. 56 00:04:22,530 --> 00:04:27,390 lSl So what I'm going to do here, I'm going to delete these two directories. 57 00:04:27,390 --> 00:04:36,240 So find then dot, then I name, then dir, then I'm going to add another option here. 58 00:04:36,240 --> 00:04:40,290 Dash, delete and hit enter lSl. 59 00:04:40,350 --> 00:04:43,920 As we can see here, we don't have these two directories anymore. 60 00:04:45,150 --> 00:04:55,930 If I would like to use the option here under under under home, I'm going to do option dash size, so 61 00:04:55,930 --> 00:04:56,980 I'm going to look. 62 00:04:57,670 --> 00:05:02,230 For doesn't matter file or directories under the slash home. 63 00:05:03,350 --> 00:05:05,450 The working directory here. 64 00:05:06,530 --> 00:05:07,400 The slash home. 65 00:05:08,480 --> 00:05:14,090 Then I'm going to say, for example, 20 Mega. 66 00:05:14,090 --> 00:05:18,350 So I'm going to look for all five directories that has the size 20 mega. 67 00:05:18,380 --> 00:05:19,130 I hit enter. 68 00:05:19,310 --> 00:05:21,150 We didn't get any outcome. 69 00:05:21,170 --> 00:05:27,130 However, I can change the search from where I can start, so I'm going to start from the top. 70 00:05:27,140 --> 00:05:34,280 From the top level, from the root directory or the root file system and hit enter and wait for a bit. 71 00:05:34,940 --> 00:05:42,110 As we can see here, we got all the out, all the files and directories that has size 20. 72 00:05:42,860 --> 00:05:46,280 Now let's move on if I would like to use another option. 73 00:05:46,280 --> 00:05:53,990 So we're going to do here the current working directory first, then the type I'm going to do file. 74 00:05:55,080 --> 00:05:55,740 Then. 75 00:05:55,740 --> 00:06:00,360 Dash So in this case, in this example, I'm going to use the permission. 76 00:06:00,360 --> 00:06:04,110 So this is the short for permission, dash perm. 77 00:06:04,110 --> 00:06:08,250 So then I'm going to type the permission. 78 00:06:08,250 --> 00:06:09,450 066. 79 00:06:09,480 --> 00:06:17,580 We will talk more about the permissions and the file ownership and permission levels in the next level, 80 00:06:17,640 --> 00:06:24,930 in the next chapter when we're going to explain more about how we can use these permissions hit enter. 81 00:06:25,110 --> 00:06:26,700 We didn't get an outcome. 82 00:06:26,700 --> 00:06:29,490 However, I can start from the top level. 83 00:06:29,490 --> 00:06:30,420 I hit enter. 84 00:06:30,570 --> 00:06:36,570 As we can see over here, we got all the files and directories that has the permission. 85 00:06:36,600 --> 00:06:39,210 066, six. 86 00:06:41,430 --> 00:06:52,020 And now we're going to do the example about how we can use the users so clear find I'm going to start 87 00:06:52,020 --> 00:06:56,550 here and this current working directory then type. 88 00:06:57,240 --> 00:07:01,530 I'm going to do directory this time, then dash user. 89 00:07:01,530 --> 00:07:06,750 So I'm going to look for all the directories that belongs to this user. 90 00:07:07,020 --> 00:07:12,630 So the user student and I hit enter didn't get anything. 91 00:07:12,630 --> 00:07:18,630 However, if I will change to start from the top level hit enter. 92 00:07:18,900 --> 00:07:27,510 As you can see here we got all the directory directory is here under this user or that or the or the 93 00:07:27,510 --> 00:07:29,670 directory that belongs to this user. 94 00:07:29,940 --> 00:07:39,840 I can do the same thing if I would like to for example, do group, then we have a group student hit 95 00:07:39,870 --> 00:07:40,950 enter. 96 00:07:40,950 --> 00:07:42,450 So you can see here we get. 97 00:07:44,030 --> 00:07:47,270 All the directories that belongs to group student. 98 00:07:48,790 --> 00:07:51,790 Now let's move on to another example here. 99 00:07:52,090 --> 00:07:55,420 So another example, if I would like to do. 100 00:07:56,200 --> 00:07:57,210 Search. 101 00:07:57,790 --> 00:08:01,240 If I would like to search text within multiple files. 102 00:08:01,840 --> 00:08:08,580 So the multiple files here, for example, I'm going to do cut month first. 103 00:08:08,590 --> 00:08:16,660 As we can see here, we have this text file and I would like to search, for example, for the month 104 00:08:16,660 --> 00:08:17,110 March. 105 00:08:17,110 --> 00:08:19,840 So I'm going to search for a keyword here. 106 00:08:19,840 --> 00:08:25,630 So I'm going to do find first, then dot the current working directory, then the type. 107 00:08:25,630 --> 00:08:30,880 So the type will be F, so the file text file, then the name here. 108 00:08:32,710 --> 00:08:37,000 So in this here, the name I have to say. 109 00:08:38,429 --> 00:08:44,470 What is it before so I name so I'm going to look for it doesn't matter which is the file. 110 00:08:44,680 --> 00:08:47,290 So it's not a specific. 111 00:08:47,310 --> 00:08:52,720 I'm not I'm not I'm not looking for a specific file for that text. 112 00:08:53,080 --> 00:08:55,060 Then after that dash. 113 00:08:55,300 --> 00:08:57,250 So I'm going to use another option here. 114 00:08:57,280 --> 00:08:58,300 E x. 115 00:08:58,420 --> 00:08:58,960 E c. 116 00:08:59,170 --> 00:09:00,700 So e x e c. 117 00:09:00,730 --> 00:09:02,230 This is the option that I would like. 118 00:09:02,230 --> 00:09:04,180 So this is an execute command. 119 00:09:05,100 --> 00:09:08,790 I'm going to execute this command after the search. 120 00:09:09,000 --> 00:09:11,700 Then I'm going to use the grip command. 121 00:09:11,910 --> 00:09:18,720 Then after the grip between a single quotation, for example, I'm going to search for. 122 00:09:19,430 --> 00:09:23,540 The word march, then close to the quotation mark. 123 00:09:23,570 --> 00:09:25,130 The single quotation mark. 124 00:09:25,340 --> 00:09:28,490 So the single quotation mark here. 125 00:09:28,520 --> 00:09:34,190 Then after that, what I'm going to use with the presses, I have to do like that. 126 00:09:34,190 --> 00:09:39,680 Then space, then the backslash, then semicolon. 127 00:09:39,800 --> 00:09:42,200 So we need to understand the structure. 128 00:09:42,200 --> 00:09:44,780 If I would like to use the execute command. 129 00:09:45,550 --> 00:09:49,030 This is how this is how it how it works. 130 00:09:49,150 --> 00:09:53,800 So I'm going to use the execute in order to run another command. 131 00:09:55,120 --> 00:09:57,610 After the find or the search command. 132 00:09:58,510 --> 00:10:00,420 Then grip. 133 00:10:00,430 --> 00:10:08,020 So what I'm going to do grip the word marsh Then I have to close it with the presses space. 134 00:10:08,020 --> 00:10:11,380 Then the backslash in a semicolon hit enter. 135 00:10:11,500 --> 00:10:14,560 As we can see here, we got the keyword. 136 00:10:14,560 --> 00:10:15,010 Marsh. 137 00:10:15,250 --> 00:10:16,020 I can do. 138 00:10:16,030 --> 00:10:17,980 I can also do it for another word. 139 00:10:17,980 --> 00:10:19,240 For example, April. 140 00:10:21,840 --> 00:10:22,860 I hit enter. 141 00:10:23,130 --> 00:10:26,220 And as you can see, we get the same output. 142 00:10:28,690 --> 00:10:34,810 Which is that one key word here, if I have the key word in a different text file. 143 00:10:35,050 --> 00:10:36,490 Let's do it here, for example. 144 00:10:36,490 --> 00:10:38,350 Let's see what we have. 145 00:10:38,860 --> 00:10:42,130 LS L and Cat. 146 00:10:43,670 --> 00:10:46,520 I will do here for the number. 147 00:10:50,470 --> 00:10:57,460 So I'm going to add, for example, here, word April, for example. 148 00:11:00,850 --> 00:11:04,270 Then I'm going to close this one and save the file. 149 00:11:06,200 --> 00:11:12,230 So let's just check that we have here the keyword and here the month. 150 00:11:13,990 --> 00:11:18,250 Okay, so we have the keywords and these two files. 151 00:11:18,250 --> 00:11:25,780 So in this case, if I'm going to do the search here defined, it means that I'm going to get two outcomes 152 00:11:25,810 --> 00:11:26,560 hit enter. 153 00:11:26,800 --> 00:11:28,870 As we can see here, we get two. 154 00:11:30,470 --> 00:11:32,840 Words of April. 155 00:11:34,340 --> 00:11:37,760 Now let's move on to another command. 156 00:11:38,210 --> 00:11:42,710 So another command is the same that I'm going to use the execute command. 157 00:11:42,710 --> 00:11:51,650 But in this case, I would like to copy all the text files in. 158 00:11:52,070 --> 00:11:54,740 So I have the first option, the type. 159 00:11:55,910 --> 00:11:59,050 File, then ignore case. 160 00:11:59,120 --> 00:12:01,100 It doesn't matter uppercase or lowercase. 161 00:12:01,100 --> 00:12:08,300 Then between a double quotation I'm going to do star dot txt so I'm going to look for all the txt files. 162 00:12:08,500 --> 00:12:14,780 Doesn't matter the name, whatever before the dot txt the extension here then e. 163 00:12:15,170 --> 00:12:19,040 So I'm going to execute and I'm going to use the copy. 164 00:12:19,040 --> 00:12:25,040 So what I'm going to do, I'm going to copy all the txt files in this current working directory. 165 00:12:25,160 --> 00:12:26,240 To where. 166 00:12:26,930 --> 00:12:30,800 To a directory under the slash home. 167 00:12:30,950 --> 00:12:33,980 So here in this case, since we're going to use the. 168 00:12:34,010 --> 00:12:43,610 CPP, which is the copy, then I have to use the process before the directory that I would like to. 169 00:12:43,730 --> 00:12:54,530 Save all the files inside that directory, then space, then the back slash semicolon hit enter. 170 00:12:55,130 --> 00:13:01,330 And dash L as we can see here now, first we have to create. 171 00:13:01,340 --> 00:13:04,160 I didn't create the directory. 172 00:13:04,160 --> 00:13:05,960 I'm going to create the directory here. 173 00:13:07,980 --> 00:13:08,830 Making directory. 174 00:13:08,850 --> 00:13:10,320 We cannot make it. 175 00:13:10,320 --> 00:13:11,120 Files exist. 176 00:13:11,130 --> 00:13:11,520 Okay. 177 00:13:11,520 --> 00:13:13,280 Let me remove that directory. 178 00:13:13,320 --> 00:13:15,120 First here. 179 00:13:16,740 --> 00:13:19,500 Then I'm going to make the directory here. 180 00:13:20,010 --> 00:13:20,760 Perfect. 181 00:13:20,760 --> 00:13:22,830 Then I'm going to run the command again. 182 00:13:23,900 --> 00:13:31,370 As we can see here, we copied all the text files to this directory. 183 00:13:31,490 --> 00:13:32,570 So we're going to reboot. 184 00:13:32,570 --> 00:13:41,060 So find this current current working directory and the type it's file then dash I name. 185 00:13:41,060 --> 00:13:44,810 So the ignore case, it doesn't matter this between the quotation marks. 186 00:13:44,810 --> 00:13:49,310 So all the text files that has the extension that the txt. 187 00:13:49,370 --> 00:13:50,330 So it doesn't matter. 188 00:13:50,330 --> 00:13:55,910 Ignore the names or all the names here or the numbers then since we're going to use the execute. 189 00:13:57,160 --> 00:13:57,790 Copy. 190 00:13:57,820 --> 00:14:03,790 So once we're going to use another command, then we have to use this. 191 00:14:03,910 --> 00:14:08,620 The process we're going to use the process with the copy here. 192 00:14:08,620 --> 00:14:14,470 And then after the process, we're going to use the the directory that we would like to save all those 193 00:14:14,470 --> 00:14:17,290 files to this directory. 194 00:14:17,290 --> 00:14:26,610 And we don't forget that we have to close the the execute command with the backslash, then a semicolon. 195 00:14:26,620 --> 00:14:27,750 Let's go inside. 196 00:14:27,760 --> 00:14:28,340 Okay. 197 00:14:28,390 --> 00:14:32,200 LZ, Dash, L as we can see here, we have this directory. 198 00:14:32,530 --> 00:14:34,420 I'm going to go inside this directory. 199 00:14:35,050 --> 00:14:45,070 LZ, l as we can see here, what we did, we copied all the files from the current working directory 200 00:14:45,070 --> 00:14:46,570 to this directory. 201 00:14:47,800 --> 00:14:48,610 The WD. 202 00:14:49,240 --> 00:14:53,770 As you can see here, we are under this current working directory. 203 00:14:54,010 --> 00:14:58,660 Now let's move on to the next command. 204 00:14:58,690 --> 00:15:06,790 So since I'm inside this current working directory, what I'm going to do here, I'm going to delete 205 00:15:06,790 --> 00:15:09,550 all the files in this current working directory. 206 00:15:09,550 --> 00:15:20,680 So WD this is the current working directory right now and find in this current working directory I name 207 00:15:22,030 --> 00:15:22,900 then. 208 00:15:24,610 --> 00:15:26,140 I'm going to just do the text. 209 00:15:26,170 --> 00:15:29,020 So the names ignore case doesn't matter. 210 00:15:29,050 --> 00:15:31,270 Upper or lower case. 211 00:15:31,270 --> 00:15:32,290 Then all the. 212 00:15:33,220 --> 00:15:41,960 Files that has the extension that txt then execute perfect. 213 00:15:42,380 --> 00:15:50,230 R m dash rf because I would like to delete all the files in this current working directory here. 214 00:15:51,490 --> 00:15:53,740 Then what I'm going to do after that? 215 00:15:53,770 --> 00:15:55,090 Close the presses. 216 00:15:55,890 --> 00:15:56,880 The space. 217 00:15:57,790 --> 00:16:02,680 Then what I'm going to do is the backslash semicolon. 218 00:16:03,460 --> 00:16:04,300 Hit, enter. 219 00:16:05,320 --> 00:16:12,670 As we can see here, we don't have any file because we removed all the text files from this. 220 00:16:13,420 --> 00:16:15,190 Current working directory. 221 00:16:16,090 --> 00:16:20,820 If I would like to find more information about this find command, I can go to the man page. 222 00:16:20,830 --> 00:16:27,940 As we can see here, we can get all the details and the options and also about this command. 223 00:16:28,720 --> 00:16:30,250 As you can see over here. 224 00:16:31,240 --> 00:16:36,940 The dash, execute then the command so we can get more information about how to use and also here how 225 00:16:36,940 --> 00:16:40,870 to use this command with the braces. 226 00:16:40,870 --> 00:16:49,660 And plus and as you can see here is that you can use it with this backslash, as we can see over here. 227 00:16:51,160 --> 00:16:56,770 Hearing this if we can use the prices and with a backslash. 228 00:16:57,550 --> 00:17:00,010 Okay, That's concludes our session. 229 00:17:00,460 --> 00:17:02,830 Thank you and see you in the next lesson.