dircolors:_ext 的规则(而不是 .ext)

use*_*963 3 ls colors

在 UNIX 中,许多文件扩展名不包含前面的点,如 inbashrc而不是bash.rcssh_config而不是ssh.config

我也想添加 dircolor 规则_config。但是,当我添加以下行时:

_config 01;31
Run Code Online (Sandbox Code Playgroud)

我收到一个错误: dircolors: `/etc/dircolors':126: unrecognized keyword _config

是否可以_ext向 dircolors添加扩展?

Mat*_*att 6

您可以使用*_config 01;31.

来自man 5 dir_colors

*extension color-sequence
    Specifies the color used for any file that ends in extension.

.extension color-sequence
    Same as *.extension. Specifies the color used for any file that ends
    in .extension. Note that the period is included in the extension, which
    makes it impossible to specify an extension not starting with a period,
    such as ~ for emacs backup files. This form should be considered obsolete.
Run Code Online (Sandbox Code Playgroud)

  • 不幸的是,它区分大小写,您不能使用正则表达式。你必须列出所有可能的排列。我检查了 `ls` 的源代码,以确保没有任何未记录的功能可以解决这个问题,但实际上并没有。这只是与文件扩展名的常规字符串比较。 (2认同)