4

if I have current path as a long one..and I want to switch to a directory with just one word from path replaced by something else..like say when using maven , I want to switch from main path to test path, how do I do it?

Some time back, I was able to do it by

$ cd main test

to replace main by test in the path, but not any more..

Any pointers...?

1 Answer 1

6

You could use a simple function for that (put it in your .bashrc or something like that):

function bcd {
    cd ${PWD/$1/$2}
}

Then you call it like this:

~/tmp $ bcd tmp src
~/src $ 
1
  • Also, cd - can be very useful in the described situation (to quickly change back and forth between the paths). Oct 30, 2011 at 21:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .