I'm trying to create a directory and cd
into it:
In ~/.bashrc:
function abc() {
appname=$1
appdir="$HOME/code/$appname"
if [ mkdir $appdir -a cd $appdir ]; then
echo Success
else
echo Failed to create and switch directory
fi
}
When I reload bashrc (. ~/.bashrc
) I get the error:
bash: [: too many arguments
Failed to create and switch directory
How do I fix this? And what does [:
in the error mean?
Ps. Could someone direct me to a "non-cryptic" bash scripting tutorial?
if <COMMANDS>; then <COMMANDS>; fi