28

I want to list all files but those ending with owp: Hence I tried:

  ls -l *.(^owp)
  zsh: unknown sort specifier
  ls -l *(^owp) 
  zsh: unknown sort specifier
  ls -l *[^o][^w][^p] # does not work either, missing some files

none worked. How do I that in a correct manner? My .zshrc has "set extendedglob".

Nifle
  • 34,998
math
  • 2,693

2 Answers2

41

Try either:

ls -l ^*.owp

(i.e. match anything except the pattern *.owp)

or:

ls -l *~*.owp

(i.e. match anything that matches the pattern * but does not match *.owp)

See man zshexpn => FILENAME GENERATION => Glob Operators for more on this.


Appended () in glob patterns are for glob qualifiers, whereas you want a glob operator.

What *.(^owp) does is:

  1. Match all file names ending with a dot
  2. if they aren't pipes (^p), and
  3. sort the matches (o) by "w" => "unknown sort specifier"

See man zshexpn => FILENAME GENERATION => Glob Qualifiers for more on this.

Sparhawk
  • 2,016
peth
  • 10,400
-1

I was having this same issue trying to pull a branch down from git.

Example:feature/this_feature(error_1)

I had to escape the parenthesis: feature/this_feature\(error_1\)