If I want to navigate inside folder with long hard-to-type name, is there way to use 'cd' with some kind of shortened name of this folder, to get free from unnecessary work?
Linux – ‘cd’ command in terminal – using partial folder name
command linelinuxterminal
Best Answer
If you know that the name is unique after a few typed letters, you can do – for example to go to the folder "FooBarBaz":
The
*
glob will expand to the name of all folders starting withFoo
, andcd
will go to the first folder found.The same works the other way around, or if the part you know is in the middle of the folder name:
This probably requires the least keypresses. You can just press Enter and it'll expand automatically.
You can get even shorter if you set the
autocd
option, assuming you use Bash, withshopt -s autocd
. It requires you only to type the directory name withoutcd
to have the shellcd
to it. For example:Of course, you can add this option to your shell's configuration file to have it loaded automatically (e.g.,
~/.bash_profile
or~/.bashrc
, depending on what you use).