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

发布于 2024-09-30 18:53:04 字数 201 浏览 1 评论 0原文

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

例如:我的 .bash_aliases 包含

alias ls='ls -ltr'

如果我只想检索文件名,是否需要将别名重命名为“ls”以外的名称?或者还有别的办法吗?

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.

eg: my .bash_aliases includes

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少钕鈤記 2024-10-07 18:53:04

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

\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

Add a \ (backslash) before the command to disable the alias, like this:

\ls

This will invoke the original (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
鲜肉鲜肉永远不皱 2024-10-07 18:53:04

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

you can use /bin/ls temporarily, or `which ls`

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文