An alias can only substitute the first word of a command with some arbitrary text. It can not use parameters.
You can instead use a shell function:
mcd()
{
test -e "$1" || mkdir "$1"
cd "$1"
}
More Related Contents:
- Make a Bash alias that takes a parameter?
- How do I run a shell script without using “sh” or “bash” commands?
- How to use aliases defined in .bashrc in other scripts?
- How to embed bash script directly inside a git alias
- How to make .bashrc aliases available within a vim shell command? (:!…)
- Why aliases in a non-interactive Bash shell do not work
- In Bash, how to add “Are you sure [Y/n]” to any command or alias?
- Can’t get expand_aliases to take effect
- Why bash alias doesn’t work in scripts? [duplicate]
- Why would I create an alias which creates a function?
- Echo newline in Bash prints literal \n
- Remove a fixed prefix/suffix from a string in Bash
- How to execute mongo commands through shell scripts?
- Should aliases go in .bashrc or .bash_profile? [duplicate]
- What is a unix command for deleting the first N characters of a line?
- Get content between a pair of HTML tags using Bash
- Conda command working in command prompt but not in bash script
- How do I escape slashes and double and single quotes in sed?
- Exporting JSON to environment variables
- Error message on Terminal launch [duplicate]
- Syntax error: “(” unexpected — with !(*.sh) in bash script
- Exit when one process in pipe fails
- How can I find out a file’s MIME type (Content-Type)?
- Jenkins pipeline sh fail with “cannot run program nohup” on windows
- How can I run a Windows executable from WSL (Ubuntu) Bash
- Find date range overlaps within the same table, for specific user MySQL
- How to pass a Bash variable to Python?
- File names with spaces in BASH
- docker error on windows : the input device is not a TTY. If you are using mintty, try prefixing the command with ‘winpty’ [duplicate]
- bash double bracket issue