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.
cd
does run - but its effect is lost as soon as the subshell running the script dies. – D_Bye Dec 08 '16 at 13:38mkcd() { if [ ! -d "$@" ];then mkdir -p "$@" ;fi; cd "$@"; }
(Posted as comment because answering is disabled here.). – neverMind9 Jun 20 '19 at 20:31