如何覆盖.bash_aliases中设置的别名

时间:2010-11-03 14:56:19

标签: bash alias

我喜欢使用bash别名来自定义bash命令。有没有办法覆盖bash别名设置,或者我应该将别名重命名为与原始命令不同的东西。

例如:我的.bash_aliases包括

alias ls='ls -ltr'

如果我只想检索文件名,是否需要将别名重命名为“ls”以外的其他名称?或者还有另一种方式吗?

2 个答案:

答案 0 :(得分:45)

在命令之前添加\(反斜杠)以禁用别名,如下所示:

\ls

这将调用原始(无锯齿)ls

示例

$ ls #will invoke the alias
total 0
-rw-rw-r--    1 dogbane foo          0 Nov  3 16:04 c
-rw-rw-r--    1 dogbane foo          0 Nov  3 16:04 b
-rw-rw-r--    1 dogbane foo          0 Nov  3 16:04 a

$ \ls #will disable the alias
a  b  c

答案 1 :(得分:4)

您可以暂时使用/bin/ls,或`which ls`