Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This could be quite a simple one, but I can't find any answer for it.

If I am in a terminal and use the cp command, is there a way of instantly cding to the target directory? For example, is there some equivalent to cp foo/file.ext ../bar/subdir/; cd ../bar/subdir/ that doesn't require retyping the path to the target folder?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You can do:

cp foo/file.ext ../bar/subdir/

followed by:

cd !$

But this won't work in one line, like cp foo/file.ext ../bar/subdir/; cd !$.

share|improve this answer
Perfect, this is exactly what I was looking for (it being on one line wasn't really a factor, just wrote it like that to keep the question neat). Ta very much! –  Jez W Jun 12 '13 at 14:23

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.