I'm trying to write a very simple mkcd command:
#!/bin/bash
mkdir $1
cd $1
The directory is created but the change directory part doesn't seem to run.
Update based on comment:
mkcd () {
mkdir "$1"
cd "$1"
}
I'm trying to run it first as a local file:
./mkcd
My end location is /opt/bin, neither location seems to work.
cddoes run - but its effect is lost as soon as the subshell running the script dies.mkcd() { if [ ! -d "$@" ];then mkdir -p "$@" ;fi; cd "$@"; }(Posted as comment because answering is disabled here.).