Shell tip: change to a directory having very long name

Posted on in Categories Howto, Linux, Shell scripting, Tip of the day, Tips, UNIX last updated June 6, 2007

Let us say your have a long directory name called “A_VERY_ VERY LONG_ DIRECTORY_NAME_TO_ TYPE _ A _ B _C”…

So how do you change to a directory, which is having very long name without typing full name?

Simply use a wildcard character called * as follows
$ cd A_VERY_VERY*

Or type cd A_VERY and hit tab key to complete a directory name 🙂
$ cd A_VERY_VERY (hit tab key)

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 3 comments/add one below):

3 comment

  1. I recommend appending the last letter as well:

    $ cd A_VERY_VERY*C

    Better example:

    $ cd /usr/lib/fire*10/plugins

    or for total brevity:

    $ cd /us*/li*/fir*10/pl* gets you to same place

    namely /usr/lib/firefox-1.5.0.10/plugins

    Have a question? Post it on our forum!