1 00:00:00,000 --> 00:00:04,200 [Intro Music] 2 00:00:04,290 --> 00:00:05,610 We have just discussed how to 3 00:00:05,610 --> 00:00:07,650 create archives, and how to compress 4 00:00:07,650 --> 00:00:09,870 them. Also, I have shown you how to 5 00:00:10,050 --> 00:00:11,370 extract contents from the 6 00:00:11,370 --> 00:00:13,350 compressed archive. And for that 7 00:00:13,350 --> 00:00:15,090 you could use just a single utility 8 00:00:15,090 --> 00:00:17,640 called 'tar'. It's very powerful utility, 9 00:00:17,820 --> 00:00:19,710 and it has a lot of different other 10 00:00:19,710 --> 00:00:22,080 options. And before going on, let 11 00:00:22,080 --> 00:00:23,850 me quickly enter a command 'file', and 12 00:00:23,850 --> 00:00:26,010 here will be path to archive, and 13 00:00:26,010 --> 00:00:27,600 recap that we have created file 14 00:00:27,630 --> 00:00:30,330 called 'archive.tar.gz', and if I 15 00:00:30,330 --> 00:00:32,009 enter such command, I will see 16 00:00:32,009 --> 00:00:34,020 actually details about this file. 17 00:00:34,200 --> 00:00:36,983 And I will see that this file is 'gzip 18 00:00:36,983 --> 00:00:39,540 compressed data'. That actually 19 00:00:39,540 --> 00:00:41,970 proves that this file was 20 00:00:41,970 --> 00:00:44,220 compressed using 'gzip' utility. 21 00:00:44,490 --> 00:00:46,260 Alright, let me quickly go one 22 00:00:46,260 --> 00:00:48,240 level up and remove this temporary 23 00:00:48,270 --> 00:00:52,050 folder, 'rm -r tmp'; and also let 24 00:00:52,050 --> 00:00:55,230 me remove 'archive.tar.gz', because I 25 00:00:55,230 --> 00:00:56,580 have placed it in the root 26 00:00:56,580 --> 00:00:58,620 directory. All right, now we are 27 00:00:58,620 --> 00:01:00,300 good to go. And in this lecture, I 28 00:01:00,300 --> 00:01:02,760 will explain you how to sort files 29 00:01:02,970 --> 00:01:04,980 and how to sort the contents of the 30 00:01:04,980 --> 00:01:07,290 file. And for that, we will use two 31 00:01:07,290 --> 00:01:10,200 commands 'ls' and 'sort'. First let 32 00:01:10,200 --> 00:01:11,700 me demonstrate to you how you could 33 00:01:11,730 --> 00:01:14,460 sort files here in this output. 34 00:01:14,760 --> 00:01:16,590 And notice that by default files 35 00:01:16,590 --> 00:01:19,200 and folders are sorted by names. 36 00:01:19,440 --> 00:01:21,330 And here you see that names start 37 00:01:21,330 --> 00:01:24,030 from 'e' and the last name has 'z' in 38 00:01:24,030 --> 00:01:25,920 my case. Alright, let me 39 00:01:25,920 --> 00:01:27,030 demonstrate to you how you could 40 00:01:27,060 --> 00:01:29,310 sort this output, for example, by 41 00:01:29,340 --> 00:01:31,920 size of every file or directory. 42 00:01:32,460 --> 00:01:35,742 Let's do following, let's 'ls --help'; 43 00:01:35,742 --> 00:01:37,500 and here I'll use 'grep'; and 44 00:01:37,500 --> 00:01:39,780 let's find all options that have 45 00:01:39,810 --> 00:01:42,450 'sort' somewhere like this. And 46 00:01:42,450 --> 00:01:44,160 I'll see that there are some 47 00:01:44,190 --> 00:01:46,110 options that have 'sort' in 48 00:01:46,110 --> 00:01:48,030 description. For example, using 49 00:01:48,060 --> 00:01:51,510 '-S', we can sort by file 50 00:01:51,510 --> 00:01:53,490 size and largest files will be 51 00:01:53,490 --> 00:01:56,190 first. Also using '--sort' 52 00:01:56,220 --> 00:01:57,660 option, please note that this 53 00:01:57,690 --> 00:02:00,253 option is different from '-S', 54 00:02:00,253 --> 00:02:01,410 because those options are 55 00:02:01,410 --> 00:02:03,450 located on different lines. This 56 00:02:03,450 --> 00:02:05,310 option has additional mandatory 57 00:02:05,340 --> 00:02:07,920 argument 'WORD'; and we could use 58 00:02:07,920 --> 00:02:11,820 here such words as 'size', 'none', and for 59 00:02:11,820 --> 00:02:14,700 example, 'time'. And with this option, 60 00:02:14,730 --> 00:02:16,860 '--sort' and argument 'time', 61 00:02:16,890 --> 00:02:19,140 we're able to sort files by 62 00:02:19,200 --> 00:02:21,540 creation or modification time. All 63 00:02:21,540 --> 00:02:23,550 right, let's now try those two 64 00:02:23,550 --> 00:02:26,651 options. And first, let's try '-S'. 65 00:02:26,651 --> 00:02:28,470 Let's clear terminal, and 66 00:02:28,470 --> 00:02:32,160 here type 'l', and 'S'; 67 00:02:32,190 --> 00:02:34,110 press Enter; and here I'll see that 68 00:02:34,110 --> 00:02:36,450 file and folders will be sorted by 69 00:02:36,480 --> 00:02:39,180 file size. Of course, we're able to 70 00:02:39,180 --> 00:02:41,760 add here additional '-h' option, 71 00:02:41,760 --> 00:02:44,700 'human'; and now we will see sizes in 72 00:02:44,700 --> 00:02:46,320 kilobytes, megabytes and so on. 73 00:02:47,190 --> 00:02:48,780 Also, we could add additional 74 00:02:48,810 --> 00:02:51,000 option 'r', that will reverse 75 00:02:51,060 --> 00:02:53,580 sorting; and now I'll see smallest 76 00:02:53,610 --> 00:02:57,090 files first. This is how we are able to 77 00:02:57,090 --> 00:03:00,450 quickly sort files by size. Now 78 00:03:00,450 --> 00:03:01,517 let's try to use 79 00:03:01,517 --> 00:03:05,310 '--sort' option. 'ls -l', and here 80 00:03:05,310 --> 00:03:07,470 let's add the option '--sort'; and here 81 00:03:07,470 --> 00:03:09,600 will be equal sign. And if I press 82 00:03:09,600 --> 00:03:11,610 Enter now, I will see actually all 83 00:03:11,610 --> 00:03:13,680 possible arguments that we are able 84 00:03:13,680 --> 00:03:15,930 to use along with this '--sort' 85 00:03:15,960 --> 00:03:18,120 option. And let's sort for example 86 00:03:18,120 --> 00:03:20,760 byte size. '--sort= 87 00:03:20,790 --> 00:03:23,820 size'. Recap that here we supply 88 00:03:23,850 --> 00:03:26,760 argument for this 'sort' option. We 89 00:03:26,760 --> 00:03:28,290 have talked about that before. All 90 00:03:28,290 --> 00:03:30,420 right, press Enter. And now I see 91 00:03:30,420 --> 00:03:34,200 that files were sorted by size. If 92 00:03:34,200 --> 00:03:36,510 I add here additional 'h' option, I 93 00:03:36,510 --> 00:03:38,580 will see actually same result as we 94 00:03:38,580 --> 00:03:40,200 have seen before, and it is 95 00:03:40,200 --> 00:03:41,680 actually alternative for 96 00:03:41,680 --> 00:03:44,850 '-S' option. All right, now 97 00:03:44,850 --> 00:03:47,550 let's try to sort by additional 98 00:03:47,580 --> 00:03:50,490 argument and that will be 'time', time 99 00:03:50,520 --> 00:03:54,030 of creation. 'time', and now we will 100 00:03:54,030 --> 00:03:55,770 see that the files will be sorted 101 00:03:55,800 --> 00:03:58,380 by modification date, and newest 102 00:03:58,410 --> 00:04:01,260 files appear here first. Notice 103 00:04:01,260 --> 00:04:03,540 that this file was modified at the 104 00:04:03,540 --> 00:04:05,700 1st June, and the last file in 105 00:04:05,700 --> 00:04:07,530 this list was modified at the 106 00:04:07,530 --> 00:04:10,980 27th May. Alright, now let's also 107 00:04:10,980 --> 00:04:13,050 sort by extension. Here will be 108 00:04:13,050 --> 00:04:16,470 'extension', like so. And now I will 109 00:04:16,470 --> 00:04:18,930 see that the 'txt' files, for example, 110 00:04:18,990 --> 00:04:21,570 will be placed at the end, 'pdf' files 111 00:04:21,570 --> 00:04:23,730 will be grouped here, 'conf' files 112 00:04:23,760 --> 00:04:25,740 will be grouped here. We have 113 00:04:25,769 --> 00:04:28,140 applied sorting by extension of the 114 00:04:28,140 --> 00:04:30,570 file. Alright, this is how you're 115 00:04:30,570 --> 00:04:33,150 able to sort the result of the 'ls' 116 00:04:33,150 --> 00:04:35,670 command. Now, let's move forward, and 117 00:04:35,700 --> 00:04:37,890 let me explain you know how to sort 118 00:04:37,890 --> 00:04:39,720 the contents of the file, but let's 119 00:04:39,720 --> 00:04:41,340 proceed after the small pause. I'll 120 00:04:41,340 --> 00:04:42,430 see you next. Bye-Bye. 121 00:04:42,430 --> 00:04:44,629 [no audio]