![](/img/trans.png)
[英]How to update all the files under the current directory in Ubuntu with some comments at the start of the files
[英]Zip together all HTML files under current directory
我希望在当前目录下递归地压缩* .html文件。
我目前的命令是:
zip all-html-files.zip *.html
但这不会递归地起作用。 似乎也没有添加-r选项。 有人可以提供建议吗? 我想压缩当前目录下的所有html文件,包括子目录下的那些文件,但只压缩HTML文件,而不是压缩文件夹。
谢谢!
那这个呢?
find /your/path/ -type f -name "*.html" | xargs zip all_html_files.zip
查找目录/your/path
下的所有.html
文件(为你的更改)。 然后,将结果传递给xargs
,从而创建zip文件。
要破坏路径,请添加-j
选项:
find /your/path/ -type f -name "*.html" | xargs zip -j all_html_files.zip
尝试
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).
find . -name "*.html" -print | zip all-html-files.zip -@
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.