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

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