2

I have a directory with files. The files all have extensions. The extensions falls in 3 types: txt, foo and bar.

I want to print all files that do not end in foo neither bar.

I already know how to list all files that does not end in foo:

set extended_glob
print ^*.foo

but how to combine that negation to also exclude *.bar?

something like

print ^(*.foo & *.bar) 

does not work. Man page did not help with this.

how to achieve the desired behaviour?

  • Go back to BASH. I tried using ZSH for about 9 months. I ended up just porting everything that I liked about oh-my-zsh and zsh back to BASH. – Charles Addis Jun 22 '16 at 20:35
2

found the answer:

print ^*.(foo|bar)
  • 2
    You could save a bit of typing by only grouping the parts that differ: print ^*.(foo|bar). Also, the zsh manual does not explicitly say so, but it is possible chain more than two options: print ^*.(foo|bar|baz). – Adaephon Jun 22 '16 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.