List files not matching a pattern?

前端 未结 9 858
我在风中等你
我在风中等你 2020-11-28 08:30

Here\'s how one might list all files matching a pattern in bash:

ls *.jar

How to list the complement of a pattern? i.e. all files not match

9条回答
  •  孤城傲影
    2020-11-28 09:12

    POSIX defines non-matching bracket expressions, so we can let the shell expand the file names for us.

    ls *[!j][!a][!r]
    

    This has some quirks though, but at least it is compatible with about any unix shell.

提交回复
热议问题