我需要压缩文件夹中的所有文件和子目录,包括以. (点)开头的文件和子目录。
我在一个名为synthesis的文件夹中,我需要压缩它下面的所有文件和子目录(但不是synthesis文件夹本身)。synthesis文件夹包含一个名为.sopc_builder的子目录,其中包含一个文件。
我尝试了以下命令
zip -r synthesis.zip *我将生成的synthesis.zip复制到另一个文件夹,并在一个文件中列出了zip内容:
unzip -l synthesis.zip > filelist.txtfilelist.txt在列表中没有.sopc_builder及其文件。
我在一些帖子中看到了一些关于Linux命令shopt的内容,但并没有真正理解它。
我使用的Linux版本是我公司的RedHatEnterpriseLinuxServer7.9。
谢谢你,格雷迪
发布于 2021-09-16 18:23:59
一种方法是将zip与find结合起来:
$ cd the/dir/you/want/to/zip
$ find . -print | zip test -@
adding: file.txt (stored 0%)
adding: .hidden/ (stored 0%)
adding: .hidden/file2.txt (stored 0%)-@ file lists. If a file list is specified as -@ [Not on MacOS],
zip takes the list of input files from standard input instead
of from the command line. For example,
zip -@ foo
will store the files listed one per line on stdin in foo.zip.
Under Unix, this option can be used to powerful effect
in conjunction with the find (1) command.
For example, to archive all the C source files in the current directory
and its subdirectories:
find . -name "*.[ch]" -print | zip source -@
(note that the pattern must be quoted to keep the shell from expanding it). https://unix.stackexchange.com/questions/669317
复制相似问题