1 00:00:00,000 --> 00:00:04,400 [Intro Music] 2 00:00:04,410 --> 00:00:06,450 Now you know how to find specific 3 00:00:06,450 --> 00:00:08,279 files with specific extensions 4 00:00:08,460 --> 00:00:11,100 using the 'find' command. And you have 5 00:00:11,100 --> 00:00:13,710 seen that it would search for files 6 00:00:13,710 --> 00:00:16,320 and folders in different paths. For 7 00:00:16,320 --> 00:00:17,700 example, you could use absolute 8 00:00:17,700 --> 00:00:20,310 path to root folder using simply 9 00:00:20,310 --> 00:00:22,440 '/', or you could omit the 10 00:00:22,680 --> 00:00:24,660 argument and in such case, 'find' 11 00:00:24,690 --> 00:00:26,940 will use the current directory you 12 00:00:26,940 --> 00:00:28,980 are currently in. Now, let me show 13 00:00:28,980 --> 00:00:31,290 you some additional examples. Let's 14 00:00:31,290 --> 00:00:34,170 try to find all files. In such 15 00:00:34,170 --> 00:00:35,940 case, you could use such command as 16 00:00:35,940 --> 00:00:38,970 ''find .'; next comes '-type' 17 00:00:39,180 --> 00:00:41,340 operator; and next you could 18 00:00:41,490 --> 00:00:43,770 type here 'f' that stands for file. 19 00:00:44,220 --> 00:00:46,020 Let's press Enter. And I have found 20 00:00:46,050 --> 00:00:49,920 all files in current directory. I 21 00:00:49,920 --> 00:00:51,900 could search for directories only. 22 00:00:51,960 --> 00:00:55,050 In such case, replace 'f' with 'd', like 23 00:00:55,050 --> 00:00:57,930 this, '-type d', directory. And now I 24 00:00:57,930 --> 00:01:01,950 have found all directories. Next, you 25 00:01:01,950 --> 00:01:04,620 could find only links, '-type 26 00:01:04,709 --> 00:01:08,700 link'. Here you see only links. But 27 00:01:08,730 --> 00:01:11,040 actually you see here only list of 28 00:01:11,040 --> 00:01:13,260 files with corresponding paths to 29 00:01:13,260 --> 00:01:15,360 every file, it is not convenient. 30 00:01:15,510 --> 00:01:17,550 And we have used before 'ls' command 31 00:01:17,670 --> 00:01:20,490 with option '-l', that has shown 32 00:01:20,520 --> 00:01:22,500 us table with the permissions, the 33 00:01:22,500 --> 00:01:24,870 size and so on. There is such 34 00:01:24,900 --> 00:01:26,730 option here in 'find' command; and 35 00:01:26,730 --> 00:01:29,940 this option is that '-ls', like so. 36 00:01:30,240 --> 00:01:32,160 Let's press Enter now. And now I 37 00:01:32,160 --> 00:01:34,830 see files in table format. But the 38 00:01:34,830 --> 00:01:36,960 formatting is a bit weird here. But 39 00:01:36,960 --> 00:01:38,580 anyway, here in the first column, 40 00:01:38,580 --> 00:01:40,830 you see inode number, afterwards you 41 00:01:40,830 --> 00:01:42,480 see here permissions, and you see 42 00:01:42,480 --> 00:01:44,460 that in all files first letter 43 00:01:44,460 --> 00:01:46,590 here is 'l', that's because we were 44 00:01:46,650 --> 00:01:49,830 looking for links. Also here you 45 00:01:49,830 --> 00:01:52,470 see user and the group, next comes 46 00:01:52,500 --> 00:01:53,790 date of modification and 47 00:01:53,790 --> 00:01:56,460 afterwards, link itself. But notice 48 00:01:56,460 --> 00:01:58,320 that this output isn't formatted 49 00:01:58,320 --> 00:01:59,730 using different colors. And it is 50 00:01:59,730 --> 00:02:01,050 not really convenient to read. 51 00:02:01,920 --> 00:02:03,750 Let's repeat the same action but 52 00:02:03,750 --> 00:02:06,390 use directories with '-ls' 53 00:02:06,390 --> 00:02:08,310 option. And now I see only 54 00:02:08,310 --> 00:02:10,590 directories, and here you see 'd' in the 55 00:02:10,590 --> 00:02:12,660 beginning of permissions sections. 56 00:02:13,470 --> 00:02:15,960 Alright. Next, you could find only 57 00:02:15,960 --> 00:02:17,760 empty files. For that you could use 58 00:02:17,820 --> 00:02:20,790 'empty' option, 'find .'; and 59 00:02:20,790 --> 00:02:23,550 let's look only for files; and 60 00:02:23,580 --> 00:02:25,950 let's add here option 'empty'. I 61 00:02:25,950 --> 00:02:28,170 am looking only for empty files in 62 00:02:28,200 --> 00:02:30,270 current directory. And for example 63 00:02:30,270 --> 00:02:32,610 here was empty file, let me copy 64 00:02:32,640 --> 00:02:35,910 its path and read this file, 'cat', and 65 00:02:35,940 --> 00:02:38,280 here will be actually result; and 66 00:02:38,280 --> 00:02:40,200 this file is really in fact empty. 67 00:02:41,130 --> 00:02:42,570 That's how you could search for 68 00:02:42,570 --> 00:02:45,210 empty files. Alright, next example. 69 00:02:45,210 --> 00:02:46,650 In the next example, let me show 70 00:02:46,650 --> 00:02:48,720 you how to search for files, 71 00:02:48,870 --> 00:02:50,820 depending on size of the file. 72 00:02:51,090 --> 00:02:54,270 So, 'find .'; and let's look only 73 00:02:54,270 --> 00:02:57,090 for files, '-type file'; and here will 74 00:02:57,090 --> 00:02:59,670 be operator '-size'; and here using 75 00:02:59,670 --> 00:03:02,190 following syntax like, '+10', 76 00:03:02,220 --> 00:03:04,320 let's say 'K', I will search for 77 00:03:04,320 --> 00:03:06,600 files that are larger than 10 78 00:03:06,630 --> 00:03:09,810 kilobytes. Let's do that. And I 79 00:03:09,810 --> 00:03:12,240 have found two files. Let's add 80 00:03:12,240 --> 00:03:14,970 here also 'ls' option; and I'll see 81 00:03:14,970 --> 00:03:17,430 actual size of those two files. And 82 00:03:17,430 --> 00:03:19,710 both sizes are larger than 10 83 00:03:19,740 --> 00:03:22,020 kilobytes. Recap that those sizes 84 00:03:22,080 --> 00:03:25,230 are in bytes here. All right, let's 85 00:03:25,260 --> 00:03:27,750 search for files that are larger 86 00:03:27,750 --> 00:03:30,480 than one megabyte, and let's look 87 00:03:30,480 --> 00:03:33,720 for files in all files and folders 88 00:03:33,750 --> 00:03:35,340 that are subfolders of 'root' 89 00:03:35,370 --> 00:03:39,210 directory. Enter. Then I found for 90 00:03:39,210 --> 00:03:41,760 example, such file as 'perl'. That is 91 00:03:41,760 --> 00:03:44,340 around three and a half megabytes. 92 00:03:45,000 --> 00:03:46,710 Also, there are other files and 93 00:03:46,740 --> 00:03:48,930 again, all files in this table are 94 00:03:48,960 --> 00:03:51,960 larger than one megabyte. But 95 00:03:51,960 --> 00:03:53,850 please notice that this output is 96 00:03:53,850 --> 00:03:55,680 not really convenient, and is not 97 00:03:55,680 --> 00:03:57,180 really nice looking, and it doesn't 98 00:03:57,180 --> 00:03:59,310 have any colors like output of 'ls' 99 00:03:59,310 --> 00:04:00,750 command; and it is actually 100 00:04:00,750 --> 00:04:02,820 possible to reformat this output 101 00:04:02,850 --> 00:04:05,100 and print it like 'ls' command 102 00:04:05,100 --> 00:04:06,660 prints. But I'll show you that in 103 00:04:06,660 --> 00:04:08,310 the next lecture. Now let me show 104 00:04:08,310 --> 00:04:10,290 you one more example. And you could 105 00:04:10,290 --> 00:04:12,240 use file permissions in order to 106 00:04:12,270 --> 00:04:14,250 find the file with specific file 107 00:04:14,250 --> 00:04:16,260 permission. And let me remove the 108 00:04:16,260 --> 00:04:18,120 'size' operator; and instead of it 109 00:04:18,120 --> 00:04:20,310 let's type here '-perm', that stands 110 00:04:20,310 --> 00:04:22,230 for permission; and as argument 111 00:04:22,260 --> 00:04:25,110 let's type here '777'; and let's 112 00:04:25,140 --> 00:04:27,420 search for such files with such 113 00:04:27,420 --> 00:04:29,520 permission only in current 114 00:04:29,550 --> 00:04:32,610 directory, like this. And actually 115 00:04:32,610 --> 00:04:35,550 no files were found. Let's modify 116 00:04:35,580 --> 00:04:38,640 this and let's search for all files 117 00:04:38,640 --> 00:04:41,370 and folders like this. And now I 118 00:04:41,370 --> 00:04:44,340 I see all links actually with read, 119 00:04:44,340 --> 00:04:45,960 write, and execute permissions for 120 00:04:45,960 --> 00:04:48,570 all users. You see those results 121 00:04:48,570 --> 00:04:50,580 here. I will explain you actually 122 00:04:50,640 --> 00:04:52,050 those permissions a bit later in 123 00:04:52,050 --> 00:04:53,910 details, and I will demonstrate to you 124 00:04:53,910 --> 00:04:55,980 how to change permissions, and we 125 00:04:55,980 --> 00:04:56,850 will talk about that 126 00:04:56,879 --> 00:04:58,589 when I explain you how to create 127 00:04:58,619 --> 00:05:01,649 executable scripts. Alright, that's 128 00:05:01,649 --> 00:05:03,419 some options that you could use 129 00:05:03,449 --> 00:05:05,939 with 'find' command; and next after the 130 00:05:05,939 --> 00:05:07,919 small pause let me explain to you how 131 00:05:07,919 --> 00:05:10,739 to execute additional command after 132 00:05:10,769 --> 00:05:13,272 'find' command. I'll see you next. Bye. 133 00:05:13,272 --> 00:05:15,690 [no audio]