别名 – 如果别名已经设置,我该怎么检查我的bashrc?

如果别名已经设置,我该如何检查我的bashrc.

当我发送一个具有函数名称的bashrc文件时,表示乐趣,而我当前的环境也有一个别名.

我尝试unalias乐趣,但这将给我一个错误,当我的环境没有这个别名时,没有找到乐趣.

所以在我的bashrc,在我的乐趣功能,我想检查是否别名设置,然后unalias.

如果您只想确定别名不存在,只需unalias它并将其错误重定向到/ dev / null,就像这样:
unalias foo 2>/dev/null

您可以检查别名是否设置如下:

alias foo 2>/dev/null >/dev/null && echo "foo is set as an alias"

正如联机帮助页所示:

For each name in the argument list for which no  value  is  sup-
plied,the  name  and  value  of  the  alias is printed.  Alias
returns true unless a name is given for which no alias has  been
defined.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...