aws 实例上的压缩文件夹会创建一个副本

PHP*_*ser 4 compression amazon-ec2

我在此路径中有一个网络应用程序

var/app/current
Run Code Online (Sandbox Code Playgroud)

我使用此命令压缩所有内容,包括 htaccess 等隐藏文件

zip -r yourfile.zip * .*
Run Code Online (Sandbox Code Playgroud)

除了包含 web 应用程序文件和文件夹的另一个副本的名为 current 的文件夹之外,它还生成包含 web 应用程序文件和文件夹的压缩文件。

如何压缩包含隐藏文件的 Web 应用程序文件和文件夹,而不将名为“当前”的目录作为副本包含在内。

Byt*_*der 6

您可能不使用.*,因为该 shell glob 也将匹配...(当前和父目录),从而导致您描述的行为。

但无论如何都没有必要,您可以单独使用该zip -r选项。让我引用手册页man zip

   -r
   --recurse-paths
          Travel the directory structure recursively; for example:

                 zip -r foo.zip foo

          or more concisely

                 zip -r foo foo

          In this case, all the files and directories in foo are saved  in
          a zip archive named foo.zip, including files with names starting
          with ".", since the recursion does not use the shell's file-name
          substitution  mechanism.  If you wish to include only a specific
          subset of the files in directory foo and its subdirectories, use
          the  -i  option  to specify the pattern of files to be included.
          You should not use -r with the name  ".*",  since  that  matches
          ".."   which will attempt to zip up the parent directory (proba?
          bly not what was intended).

          Multiple source directories are allowed as in

                 zip -r foo foo1 foo2

          which first zips up foo1 and then foo2, going down  each  direc?
          tory.

          [...]
Run Code Online (Sandbox Code Playgroud)

因此,您只需指定要压缩的文件夹,例如:

zip -r yourfile.zip /var/app/current
Run Code Online (Sandbox Code Playgroud)

或者,如果您当前的目录已经是/var/app/current,只需:

zip -r yourfile.zip .
Run Code Online (Sandbox Code Playgroud)