尝试
find . -type f -name "*.html" | xargs zip all-html-files
你也可以说
find . -type f -name "*.html" | zip all-html-files -@
如果您不想保留目录结构,请指定-j
选项:
find . -type f -name "*.html" | zip -j all-html-files -@
man zip
说:
-@ 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).
-j
--junk-paths
Store just the name of a saved file (junk the path), and do not
store directory names. By default, zip will store the full path
(relative to the current directory).