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.

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

Quite often I need to perform this two commands:

mkdir abc
cd abc

I am curious whether there is a simple command (or an alias that I can create and use) to do it in one go, like

user@GROUP:~$ mdcd abc

Is this possible?

share|improve this question

marked as duplicate by devnull, slm, Anthon, Ramesh, derobert May 5 '14 at 18:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 11 down vote accepted

Add this to your .bashrc:

mdcd() {
    mkdir "$@" && cd "$@"

Logout and login again or start a new shell to make the change.

share|improve this answer
Perfect, thank You very much!!! – shadyyx May 5 '14 at 14:36
If it solves your issue, you should accept the answer. – HalosGhost May 5 '14 at 15:08
Heh, exactly what I've been using for the past few years! No need to restart the shell though: just use source ~/.bashrc. – deltab May 5 '14 at 18:12

You could also simply do the following:

mkdir <name>; cd $_
share|improve this answer

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