找不到正确匹配的匹配项
No matches found for correct globbing
我想列出除 .mod.c 文件之外的所有 .c 文件。我将 zsh 5.2 (x86_64-debian-linux-gnu) 与 oh-my-zsh 一起使用。我使用的模式如下:
$ ls *.c
ipmi_bt_sm.c ipmi_devintf.mod.c ipmi_msghandler.c
ipmi_powernv.c ipmi_poweroff.mod.c ipmi_si.mod.c
ipmi_ssif.c ipmi_watchdog.mod.c ipmi_devintf.c
ipmi_kcs_sm.c ipmi_msghandler.mod.c ipmi_poweroff.c
ipmi_si_intf.c ipmi_smic_sm.c ipmi_watchdog.c
$ ls *.c~mod.c
zsh: no matches found: *.c~mod.c
$ ls .*.c~aoesuthaoestuhsththsh
zsh: no matches found: .*.c~aoesuthaoestuhsththsh
我确定“*.c~mod.c”是正确的,因为这正是以下网站提出的建议。
ls *.c~lex.c matches all .c files except lex.c
我是否必须为扩展通配启用特定的功能?或者禁用一些阻碍此功能的东西?
首先,您需要确保扩展通配符已打开:
setopt extended_glob
(您可能需要 .zshrc
)
至于你的模式,你想要的是*.c~*.mod.c
。
它的工作方式是 pattern1~pattern2
,它会生成 pattern1
的所有匹配项,减去 pattern2
的所有匹配项。你拥有的是 "Everything that ends in .c, minus mod.c"。你要的真的是"eveything that ends in .c, minus everything that ends in .mod.c",也就是我上面给的
我想列出除 .mod.c 文件之外的所有 .c 文件。我将 zsh 5.2 (x86_64-debian-linux-gnu) 与 oh-my-zsh 一起使用。我使用的模式如下:
$ ls *.c
ipmi_bt_sm.c ipmi_devintf.mod.c ipmi_msghandler.c
ipmi_powernv.c ipmi_poweroff.mod.c ipmi_si.mod.c
ipmi_ssif.c ipmi_watchdog.mod.c ipmi_devintf.c
ipmi_kcs_sm.c ipmi_msghandler.mod.c ipmi_poweroff.c
ipmi_si_intf.c ipmi_smic_sm.c ipmi_watchdog.c
$ ls *.c~mod.c
zsh: no matches found: *.c~mod.c
$ ls .*.c~aoesuthaoestuhsththsh
zsh: no matches found: .*.c~aoesuthaoestuhsththsh
我确定“*.c~mod.c”是正确的,因为这正是以下网站提出的建议。
ls *.c~lex.c matches all .c files except lex.c
我是否必须为扩展通配启用特定的功能?或者禁用一些阻碍此功能的东西?
首先,您需要确保扩展通配符已打开:
setopt extended_glob
(您可能需要 .zshrc
)
至于你的模式,你想要的是*.c~*.mod.c
。
它的工作方式是 pattern1~pattern2
,它会生成 pattern1
的所有匹配项,减去 pattern2
的所有匹配项。你拥有的是 "Everything that ends in .c, minus mod.c"。你要的真的是"eveything that ends in .c, minus everything that ends in .mod.c",也就是我上面给的