linux-command/command/unalias.md

62 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unalias
===
删除由alias设置的别名
## 概要
```shell
unalias [-a] name [name ...]
```
## 主要用途
- 删除一个或多个别名。
- 删除全部已定义的别名。
## 选项
```shell
-a删除全部已定义的别名。
```
## 参数
name指定要删除的一个或多个已定义的别名。
### 返回值
unalias返回true除非您要删除的别名未定义。
## 例子
```shell
# 删除全部已定义的别名
unalias -a
# 删除已定义的别名(假设当前环境存在以下别名)
unalias vi
unalias ls grep
```
## 错误用法
- 要删除的别名未定义。
- 不使用-a选项时没有传递name参数。
### 注意
1. **执行脚本时请注意:**
> 使用`source`命令执行的bash脚本如果执行了`alias`或`unalias`命令,那么有可能会对终端环境的别名设置产生影响;终端环境的别名设置也可能改变运行结果;
>
> 通过`sh`方式调用的bash脚本或直接运行当前用户有执行权限的脚本不受终端环境的别名影响。
2. 查看及设置别名,请查看`alias`命令。
3. 该命令是bash内建命令相关的帮助信息请查看`help`命令。
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->