An alias is identified by its name, and has a single definition. Since it overrides commands with the same name, for sure, there will be no interference if the alias name is only part of an existing command. Short answer is thus: yes, alias be part of the string you type on the command line.
Set up three aliases, env1
, env2
and env3
.
alias env1="env1_machineName"
alias env2="env2_machineName"
alias env3="env3_machineName"
- For daily use, an alias behaves like a command. Anything you type after
env1
, env2
or env3
will be passed to the command defined by the alias, (same_command
in this case).
- Beware that an alias is only effective in the current interactive shell. An alias exists in the current interactive shell only. An alias cannot be executed from within a script, even if defined there, unless the script is "sourced" within the current shell (
source
or .
).
If in contrast, you want the tree aliases to execute the same command (since you also said)
| So I'd like that the same command be executed if I on the command line type in env1, or env2 or env3 followed by anything else.
then just define them three times to represent the same command:
alias env1="samecommand"
alias env2="samecommand"
alias env3="samecommand"