-1

This question already has an answer here:

How can I create a reliable alias or function that let me create and cd into one directory?

I tried the following, but, as an example can't create directories with spaces.

mcd () {
        mkdir $1 && cd $1
}

marked as duplicate by cuonglm, Anthon, jimmij, slm Feb 14 '15 at 18:42

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.

  • 2
    Always quote your arguments, "$1" instead of plain $1 – roaima Feb 14 '15 at 15:03
3

Always put double quotes between variable in bash to avoid space problem ;)

mcd () {
    mkdir "$1" && cd "$1"

}

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