Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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...?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

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 $ 
share|improve this answer
    
Also, cd - can be very useful in the described situation (to quickly change back and forth between the paths). –  rozcietrzewiacz Oct 30 '11 at 21:21
add comment

Your Answer

 
discard

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.