1 00:00:00,090 --> 00:00:09,960 Hello in this video we are going to learn how we can use the tab key on our keyboard to automatically 2 00:00:10,050 --> 00:00:13,110 complete filenames and directories. 3 00:00:13,110 --> 00:00:19,320 Right now I am on my desktop and as you can see I have very very long directory names and very hard 4 00:00:19,320 --> 00:00:20,130 ones. 5 00:00:20,190 --> 00:00:21,270 Very bizarre. 6 00:00:21,300 --> 00:00:22,400 Right. 7 00:00:22,500 --> 00:00:29,070 So what if I want to change to this directory thought we only know the naive way of just simply typing 8 00:00:29,070 --> 00:00:30,390 the directory name. 9 00:00:30,390 --> 00:00:41,400 So if we want to change this one I have to type the full name which is A B C D F G H I J K L M N O P 10 00:00:41,400 --> 00:00:41,840 Q. 11 00:00:42,030 --> 00:00:45,520 And I'm finally able to change to this directory. 12 00:00:45,720 --> 00:00:50,880 But I'm sure many of you guys will ask Is this the only way of doing this. 13 00:00:50,880 --> 00:00:52,110 Is there an easy way. 14 00:00:52,200 --> 00:00:55,070 And the answer is of course yes. 15 00:00:55,080 --> 00:01:00,950 So if you just type CD and you include the first few letters of your directory name. 16 00:01:00,990 --> 00:01:07,380 So for example in this case I would just type A B and then you press your tab key once if you press 17 00:01:07,380 --> 00:01:08,430 your tab key. 18 00:01:08,430 --> 00:01:11,730 This will automatically complete your directory name for you. 19 00:01:12,030 --> 00:01:14,050 OK let's do it one more time. 20 00:01:14,550 --> 00:01:20,700 So you just simply type your commands CD and then you include the first few letters of your directory 21 00:01:20,700 --> 00:01:22,740 name which is a B. 22 00:01:23,220 --> 00:01:24,120 OK. 23 00:01:24,660 --> 00:01:27,140 And then you just press your tab key once. 24 00:01:27,150 --> 00:01:30,650 And this will automatically complete the directory name for you. 25 00:01:30,700 --> 00:01:33,090 OK let's do it with the other ones. 26 00:01:33,240 --> 00:01:38,380 OK so as you can see here I have this directory name that contains a lot of spaces right. 27 00:01:38,640 --> 00:01:40,730 And it will take me forever to write it in. 28 00:01:40,740 --> 00:01:45,200 However if I just include the first few letters so l I. 29 00:01:45,360 --> 00:01:47,040 And then I press my tab key. 30 00:01:47,100 --> 00:01:50,160 This will automatically complete my directory name for me. 31 00:01:50,930 --> 00:01:57,320 And I go back one more time and do it for this directory here that contains many special characters 32 00:01:57,350 --> 00:01:59,870 which will take me forever to insert. 33 00:01:59,870 --> 00:02:00,960 Also right. 34 00:02:00,980 --> 00:02:07,820 So I'll just say see the Dio and then tab and as you can see it automatically completes the directory 35 00:02:07,820 --> 00:02:08,620 name for me. 36 00:02:08,750 --> 00:02:09,580 Awesome. 37 00:02:09,740 --> 00:02:15,550 So this is actually very useful guys and you'll see the it will save you a lot of typing right. 38 00:02:16,010 --> 00:02:19,100 OK let's do one more example here. 39 00:02:19,190 --> 00:02:22,090 Here as you can see I have two directories. 40 00:02:22,190 --> 00:02:25,520 One two three four and one two all the way until nine. 41 00:02:25,730 --> 00:02:30,650 What if I want to change to this guy here from one all the way until nine. 42 00:02:30,740 --> 00:02:38,810 So I'll say See the one right because one of the first is the first letter here and I will press my 43 00:02:38,810 --> 00:02:39,320 tab key. 44 00:02:39,320 --> 00:02:44,900 However I think in see it only goes it only automatically completes this guy. 45 00:02:44,900 --> 00:02:52,790 However if I still insist that I want to go to the lower directory I just have to type 5 and then press 46 00:02:53,120 --> 00:02:59,150 tab again and this will automatically complete the directory name of the lower one. 47 00:02:59,180 --> 00:03:06,180 This happens because as you can see one two three four is a subset of 1 2 3 4 5 6 7 8 9. 48 00:03:06,290 --> 00:03:13,310 And so whenever you like whenever you have this kind of case here if you have like to file names and 49 00:03:13,310 --> 00:03:17,290 one of them is a subset of the other one it will go to the shorter one. 50 00:03:17,360 --> 00:03:21,530 But if you insist you can just type one letter of the other one. 51 00:03:21,530 --> 00:03:22,300 The longer one. 52 00:03:22,380 --> 00:03:25,160 And it will go to go do it right. 53 00:03:25,160 --> 00:03:26,640 So let's do it one more time. 54 00:03:27,110 --> 00:03:32,970 See the one it will go to the shorter one and then you just type five and then you press start again. 55 00:03:32,990 --> 00:03:35,800 This will go to the longer one of awesome. 56 00:03:35,960 --> 00:03:36,640 OK. 57 00:03:37,100 --> 00:03:42,080 So what if you actually said life GDP for example and then you press your tab key. 58 00:03:42,170 --> 00:03:44,730 Nothing will happen if you keep pressing your turkey. 59 00:03:44,870 --> 00:03:46,640 Nothing will happen at all right. 60 00:03:46,640 --> 00:03:52,260 It is because there is no direct read here that contains p o. 61 00:03:53,350 --> 00:03:54,950 In the first letter is right. 62 00:03:55,100 --> 00:03:56,450 So this will not work. 63 00:03:56,450 --> 00:04:05,030 So in order for this tab key completion thing to work it has to be unambiguous the file or directory 64 00:04:05,030 --> 00:04:05,850 has to exist. 65 00:04:05,870 --> 00:04:06,840 OK. 66 00:04:07,640 --> 00:04:15,260 And you can also do it for files like this guy here if I want to for example update the timestamp of 67 00:04:15,260 --> 00:04:16,060 this guy. 68 00:04:16,100 --> 00:04:22,430 All I need to do is just say touch and then a V and then you press your tab key and I'm done. 69 00:04:23,160 --> 00:04:23,640 OK. 70 00:04:23,660 --> 00:04:24,130 Awesome. 71 00:04:24,120 --> 00:04:33,740 So this is how you can automatically complete the file names and the directory names of your of your 72 00:04:34,160 --> 00:04:37,660 files in Linux using the tab key. 73 00:04:37,810 --> 00:04:38,670 OK. 74 00:04:38,990 --> 00:04:46,170 Actually there is another use a very useful use of the tab key which is suggesting. 75 00:04:46,190 --> 00:04:47,560 So what I mean by that. 76 00:04:47,680 --> 00:04:49,790 So let's clear our terminal here. 77 00:04:50,710 --> 00:04:51,890 And last favorite example. 78 00:04:51,890 --> 00:04:55,920 LS If I type ls and you press your tab key twice. 79 00:04:56,050 --> 00:05:04,580 Ok this will suggest to me all the directories that I am that I may be interested to list. 80 00:05:05,030 --> 00:05:11,120 And if I have for example I do it for the cd command and you press your tab key twice this will suggest 81 00:05:11,120 --> 00:05:18,830 to me all the directory that are available for me to CD into it or to change to OK so pressing your 82 00:05:18,830 --> 00:05:21,500 tab key twice will open up suggestions. 83 00:05:21,500 --> 00:05:24,980 And actually it can also show you a lot of options. 84 00:05:24,980 --> 00:05:27,450 So for example I know that are in command right. 85 00:05:27,650 --> 00:05:36,020 If I say our dash dash and then you press the tab key twice this will show you all the command options 86 00:05:36,230 --> 00:05:38,510 that you can use with the or in command. 87 00:05:38,510 --> 00:05:41,210 Of course many of you will say what is this. 88 00:05:41,270 --> 00:05:42,920 I didn't know about this before. 89 00:05:43,070 --> 00:05:51,410 But however for example here dash dash verbose it does seem as dash and dash dash interactive is the 90 00:05:51,410 --> 00:05:57,130 same as dash and dash dash forth the same dash and so on. 91 00:05:57,260 --> 00:06:03,360 And here you have dash dash recursive is a theme a dash or OK. 92 00:06:03,770 --> 00:06:11,600 So as you can see it pressing the tab key twice can show you a list of options that you can use with 93 00:06:12,440 --> 00:06:13,640 a given command. 94 00:06:13,880 --> 00:06:17,660 OK so that's it for this video I hope you guys enjoyed it. 95 00:06:17,660 --> 00:06:18,250 Ciao.