Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
尝试创建:
alias mcd="mkdir $1; cd $1"
得到:
$ mcd foo usage: mkdir [-pv] [-m mode] directory ... -bash: foo: command not found
我究竟做错了什么?
别名只能用一些任意文本替换命令的第一个单词。它不能使用参数。
您可以改为使用 shell 函数:
mcd() { test -e "$1" || mkdir "$1" cd "$1" }