我想简单地定义一个自定义shell命令,例如:
我输入abc并输出一些文本.
喜欢:
$ abc
The quick brown fox jumps over the lazy dog.
Run Code Online (Sandbox Code Playgroud)
你也应该考虑学习bash函数,这样你就可以了
function abc () {
echo The quick brown fox jumps over the lazy dog.
}
Run Code Online (Sandbox Code Playgroud)
而正如其他人告诉你的那样,你也可以使用bash aliasbuiltin.
您可能希望删除特定于bash的function关键字以便移植到其他Posix shell.
bash中函数的主要优点是它们可以采用一些参数并且比alias提供给你的更复杂.
尝试别名
alias abc="echo The quick brown fox jumps over the lazy dog."
Run Code Online (Sandbox Code Playgroud)
您可以将它添加到您的 ~/.bash_profile 中以使其对所有会话都有效。
| 归档时间: |
|
| 查看次数: |
4811 次 |
| 最近记录: |