Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was just at a lecture, where I noticed the lecturer using a command (probably aliased) to jump to a specific folder.


~/code$ j sciproj

This looked quite slick, so I started wondering:

Is this a standard utility, and if so, what is the name?

I have two theories as to how it works:

  1. It can both create, delete and jump to aliases directly from the command-line in the style of the example, without having to set up aliases in a configuration file or script or whatnot manually.

  2. It searches the home directory for a folder matching the name and jumps to it.

The second option seems a bit slow, however, so the first would be preferred.

share|improve this question
up vote 6 down vote accepted

As an addition to sagarchalise's comment:

It's in natty:

Should work in older releases as well.

share|improve this answer
Excellent; looks like the thing he was using. – Sebastian Paaske Tørholm Feb 11 '11 at 12:34
It's not in maverick, is it? – Stefano Palazzo Feb 11 '11 at 13:02

How about this?

function j() { for dir in ~/projects/$@*; do if [ -d $dir ]; then cd "$dir"; fi; done ;}

It finds the nearest possible match. So say I have a dir listing like this:


j a will match both apples* dirs but as apples-and-pears is the later, it will cd into that last, and that's where you'll end up (the flaw in this function). j c will put you in ~/projects/cabbage/.

Bung that into a terminal to test it and when you're happy, just plonk it on the end of ~/.bashrc.

Edit: I've also been playing around making a find variant but it's not as good (slower and less accurate). Feel free to hack around with it though.

function j() { cd $(find ~/projects -maxdepth 1 -type d -name "$@*"); }
share|improve this answer
It's gonna be reeeaaaally slooooww... – ulidtko Feb 11 '11 at 16:35

Usually you can use popd, pushd and dirs to jump between some folders. But in your case, it's some custom alias which you can define in your ~/.bash_profile file.

In example:

# Change dir via find
# Usage: cdf (dir)
cdf() {
  pushd $(find . -name $1)

And then cdf some_dir will jump into folder ignoring the sub-dirs.

Live example to search for exact folder names (ignore prompt):

~/$ cdf() { pushd $(find . -name $1); }
~/$ mkdir -p ab/cd/ef/gh/ij/kl
~/$ cdf kl
    ~/ab/cd/ef/gh/ij/kl ~/
~/$ pwd
kl$ popd # We're going back to our previous folder.
~/$ pwd

To similar alias for folders containing a partial text:

cdf() { pushd $(find . -name \*$1\*); }

Example .bash_profile file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.