I want to list all .c files, except .mod.c files. I use zsh 5.2 (x86_64-debian-linux-gnu) with oh-my-zsh. The pattern I use is following:
$ 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
I'm sure that '*.c~mod.c' is correct, because this is exactly what is proposed at following web-site.
ls *.c~lex.c matches all .c files except lex.c
Do I have to enable something specific for extended globbing? Or disable something which hinders this function?
答案 0 :(得分:1)
首先,您需要确保启用扩展globbing:
setopt extended_glob
(您可能希望.zshrc
)
至于你的模式,你想要的是*.c~*.mod.c
。
它的工作方式是pattern1~pattern2
,它会产生pattern1
的所有匹配项,减去pattern2
的所有匹配项。你所拥有的是什么"所有以.c结尾的东西,减去mod.c"。你想要的是真正的以#c结尾的东西,减去以.mod.c"结尾的所有内容,这就是我在上面给出的内容。