



(10 ratings)
< How file name completion works >
Working at the Linux command line requires a lot of typing. It would get very frustrating with long commands and file names, but luckily your Tab key can make your life a lot easier.
You have to type only the
beginning of a command, directory, or a file name, hit the Tab key and
the shell completes the rest! For example, if you want to view a file
called unBELIEVABLY-LongANDstupid.FileName.txt, all you have to type is
something like:$ less un
and hit the Tab key. The rest of the monster file name is completed
automatically and you don't necessarily have to even remember the whole
file name! It's that simple.
< Files starting with same letters >
There may be several files that start with the same letters but have different endings. How the shell behaves when you press the Tab key in this case, may differ depending on the shell and how it's configured. Usually with a default bash configuration, when you've typed the first letters of a file name and hit the Tab key, the shell completes as much as it can and beeps. When you press the Tab key again, the shell shows you all the alternatives. Sometimes you'll have to hit Tab twice before it shows you the alternatives.
Now you can either type the whole file name, or type a couple more letters and hit Tab again.
We'll
have an example: suppose you have files called
unBELIEVABLY-LongANDstupid.FileName.txt and unBELIEVABLEfile.txt and
you want to view the other file. Again, you try typing$ less un
and hit the Tab key. However, now the shell completes as much as it can and beeps:$ less unBELIEVABL
Now if you hit the Tab key again, either once or twice, the shell shows you the alternatives:
$ less unBELIEVABL
unBELIEVABLY-LongANDstupid.FileName.txt unBELIEVABLEfile.txt
Now you can type$ less unBELIEVABLY
and hit Tab again. Now the shell knows which file you mean and completes the rest.
The shell you are using may behave a bit differently, so go ahead and experiment with your command line for a while. Pretty quickly you'll get the hang of this feature, you'll start using it all the time, and you won't survive without file name completion anymore!
< What can be completed >
You can complete anything: commands, program names, directories, and file names. Just try it!
For example, to issue the command umount /mnt/floppy, you can first type um, hit Tab, then type /mn, hit Tab, then type f, hit Tab, and that's it!
20 Random Tutorials from the same category :
How to change a file's owner and group in Linux
Access Windows partitions from Linux
Asking questions in a discussion forum
The powerful bash wildcards
Text scrolling off the screen?
Wildcards, Quotes, Back Quotes and Apostrophes in shell commands ( * ? [] " ` ')
Installing software from source in Linux
Linux command line terminology
Redirection in Linux
What's a window manager?
Debugging "C" And "C++" Programs Using "gdb"
Compiling A Single-Source "C" Program
Multi-Threaded Programming With POSIX Threads
Automating Program Compilation - Writing Makefiles
A Quick Introduction to Bash Programming - Part 2
Scheduling tasks using Cron - Part II
Unix Multi-Process Programming and Inter-Process Communications (IPC)
Manipulating files in Linux
Linux file permissions
Parallel Programming - Basic Theory For The Unwary













