Let’s say you are at the root directory and want to change your working directory to the following location:
Now you would normally type the whole directory path in there like so
$ cd /home/superuser/documents/littleHandyTips/articles/linux
Now that’s a little painstaking to type isn’t it?
You might get away with using a relative path, but that really depends on where you are.
You might also, depending on the shell you’re using, be able to use the <tab> key to auto complete each directory as you type them out.
There’s actually an easier way to do that. Yes there is, it’s using regular expressions.
Most of you would probably already be familiar with regular expressions, but never thought it would work with the cd command.
So to get to the directory mentioned above you can use the following command.
$ cd /*/superuser/documents/*/*/linux
$ cd /*/*/*/*/articles/linux
$ cd /*/*/*/*/*/linux
Try it next time you’re using a shell. It’ll say you heaps of time!
p.s: It even works with dos too!