Reputation: 1798
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?
Upvotes: 1
Views: 1208
Reputation: 2655
Firstly, you need to make sure extended globbing is turned on:
setopt extended_glob
(You'll probably want that in .zshrc
)
As for your pattern, what you want is *.c~*.mod.c
.
The way it works is pattern1~pattern2
, and it yields all the matches of pattern1
, minus all the matches of pattern2
. What you had was "Everything that ends in .c, minus mod.c". What you want is really "eveything that ends in .c, minus everything that ends in .mod.c", which is what I give above.
Upvotes: 2