bash 如何覆盖 .bash_aliases 中设置的别名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4088357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how can I override alias set in .bash_aliases
提问by David LeBauer
I like to use bash aliases to customize bash commands. Is there a way to override the bash alias settings, or should I rename the aliases to something different than the original command.
我喜欢使用 bash 别名来自定义 bash 命令。有没有办法覆盖 bash 别名设置,或者我应该将别名重命名为与原始命令不同的名称。
eg: my .bash_aliases includes
例如:我的 .bash_aliases 包括
alias ls='ls -ltr'
If I want to only retrieve the file name, do I need to rename the alias to something other than 'ls'? Or is there another way?
如果我只想检索文件名,是否需要将别名重命名为“ls”以外的名称?或者还有其他方法吗?
回答by dogbane
Add a \(backslash) before the command to disable the alias, like this:
\在命令前添加(反斜杠)以禁用别名,如下所示:
\ls
\ls
This will invoke the original (un-aliased) ls.
这将调用原始 (un-aliased) ls。
Example:
示例:
$ 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
回答by Benoit
you can use /bin/lstemporarily, or `which ls`
你可以/bin/ls暂时使用,或者`which ls`

