Hello in this video we are going to learn how we can use the tab key on our keyboard to automatically
complete filenames and directories.
Right now I am on my desktop and as you can see I have very very long directory names and very hard
ones.
Very bizarre.
Right.
So what if I want to change to this directory thought we only know the naive way of just simply typing
the directory name.
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
Q.
And I'm finally able to change to this directory.
But I'm sure many of you guys will ask Is this the only way of doing this.
Is there an easy way.
And the answer is of course yes.
So if you just type CD and you include the first few letters of your directory name.
So for example in this case I would just type A B and then you press your tab key once if you press
your tab key.
This will automatically complete your directory name for you.
OK let's do it one more time.
So you just simply type your commands CD and then you include the first few letters of your directory
name which is a B.
OK.
And then you just press your tab key once.
And this will automatically complete the directory name for you.
OK let's do it with the other ones.
OK so as you can see here I have this directory name that contains a lot of spaces right.
And it will take me forever to write it in.
However if I just include the first few letters so l I.
And then I press my tab key.
This will automatically complete my directory name for me.
And I go back one more time and do it for this directory here that contains many special characters
which will take me forever to insert.
Also right.
So I'll just say see the Dio and then tab and as you can see it automatically completes the directory
name for me.
Awesome.
So this is actually very useful guys and you'll see the it will save you a lot of typing right.
OK let's do one more example here.
Here as you can see I have two directories.
One two three four and one two all the way until nine.
What if I want to change to this guy here from one all the way until nine.
So I'll say See the one right because one of the first is the first letter here and I will press my
tab key.
However I think in see it only goes it only automatically completes this guy.
However if I still insist that I want to go to the lower directory I just have to type 5 and then press
tab again and this will automatically complete the directory name of the lower one.
This happens because as you can see one two three four is a subset of 1 2 3 4 5 6 7 8 9.
And so whenever you like whenever you have this kind of case here if you have like to file names and
one of them is a subset of the other one it will go to the shorter one.
But if you insist you can just type one letter of the other one.
The longer one.
And it will go to go do it right.
So let's do it one more time.
See the one it will go to the shorter one and then you just type five and then you press start again.
This will go to the longer one of awesome.
OK.
So what if you actually said life GDP for example and then you press your tab key.
Nothing will happen if you keep pressing your turkey.
Nothing will happen at all right.
It is because there is no direct read here that contains p o.
In the first letter is right.
So this will not work.
So in order for this tab key completion thing to work it has to be unambiguous the file or directory
has to exist.
OK.
And you can also do it for files like this guy here if I want to for example update the timestamp of
this guy.
All I need to do is just say touch and then a V and then you press your tab key and I'm done.
OK.
Awesome.
So this is how you can automatically complete the file names and the directory names of your of your
files in Linux using the tab key.
OK.
Actually there is another use a very useful use of the tab key which is suggesting.
So what I mean by that.
So let's clear our terminal here.
And last favorite example.
LS If I type ls and you press your tab key twice.
Ok this will suggest to me all the directories that I am that I may be interested to list.
And if I have for example I do it for the cd command and you press your tab key twice this will suggest
to me all the directory that are available for me to CD into it or to change to OK so pressing your
tab key twice will open up suggestions.
And actually it can also show you a lot of options.
So for example I know that are in command right.
If I say our dash dash and then you press the tab key twice this will show you all the command options
that you can use with the or in command.
Of course many of you will say what is this.
I didn't know about this before.
But however for example here dash dash verbose it does seem as dash and dash dash interactive is the
same as dash and dash dash forth the same dash and so on.
And here you have dash dash recursive is a theme a dash or OK.
So as you can see it pressing the tab key twice can show you a list of options that you can use with
a given command.
OK so that's it for this video I hope you guys enjoyed it.
Ciao.