单独Gzip多个文件,并保留原始文件 [英] Gzip multiple files individually and keep the original files
本文介绍了单独Gzip多个文件,并保留原始文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用以下命令来处理单个文件:
/ p>
查找。 -type f -name* cache.html-exec gzip {} \;
或
gzip * cache.html
但不保留原始值。我尝试了
查找。 -type f -name* cache.html-exec gzip -c {}> {} .gz
,但只生成了一个{} .gz文件。
解决方案
您的>
在最后一个命令由同一个shell运行 find
解析。使用嵌套的shell:
查找。 -type f -name* cache.html-exec sh -cgzip< {}> {} .gz\;
I am looking to gzip multiple files (into multiple .gz files) in a directory while keeping the originals.
I can do individual files using these commands:
find . -type f -name "*cache.html" -exec gzip {} \;
or
gzip *cache.html
but neither preserves the original. I tried
find . -type f -name "*cache.html" -exec gzip -c {} > {}.gz
but that only made a {}.gz file. Is there a simple way to do this?
解决方案
Your >
in the last command gets parsed by the same shell which runs find
. Use a nested shell:
find . -type f -name "*cache.html" -exec sh -c "gzip < {} > {}.gz" \;
这篇关于单独Gzip多个文件,并保留原始文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文