删除文件夹中的所有文件减去一个压缩文件

如何从命令行删除一个文件夹中的所有文件减去一个文件(.zip)? 我正在使用bash ssh到我想要执行此操作的服务器。 我知道我可以在该文件夹中使用rm -rf * ,但是我需要保留压缩文件,因为它包含所有新文件来replace其他文件。 我如何从命令行执行此操作?

 $ shopt -s extglob $ rm -fr !(*.zip) 

info "(bash) Pattern Matching"

  If the extglob shell option is enabled using the shopt builtin, several extended pattern matching opera‐ tors are recognized. In the following description, a pattern-list is a list of one or more patterns sep‐ arated by a |. Composite patterns may be formed using one or more of the following sub-patterns: ?(pattern-list) Matches zero or one occurrence of the given patterns *(pattern-list) Matches zero or more occurrences of the given patterns +(pattern-list) Matches one or more occurrences of the given patterns @(pattern-list) Matches one of the given patterns !(pattern-list) Matches anything except one of the given patterns 

find . ! -name 'file.zip' -delete

男人find