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
}
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
}
Always put double quotes between variable in bash to avoid space problem ;)
mcd () {
mkdir "$1" && cd "$1"
}
"$1"
instead of plain$1
– Chris Davies Feb 14 '15 at 15:03