Bash脚本:gzip的整个文件夹,并保持文件扩展名相同 [英] Bash script: Gzip an entire folder and keep files extensions same

查看:110
本文介绍了Bash脚本:gzip的整个文件夹,并保持文件扩展名相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要gzip压缩的文件夹中的每个文件递归并保留原始名和扩展名后COM pression。

I want to gzip every file in a folder recursively and keep the original name and extension after compression.

我曾尝试须藤的gzip -9 -r文件夹但是现在每一个文件都有一个扩展名为.gz添加到原来的如 2852b65c1d8b.css 。广州,而我想保持名称 2852b65c1d8b.css 的gzip压缩文件上传到Amazon S3。

I have tried sudo gzip -9 -r folder however now each file has an .gz extension added to the original such as 2852b65c1d8b.css.gz while I want to keep the name as 2852b65c1d8b.css for the gzipped file to upload to Amazon S3.

推荐答案

使用这个你想要做什么:

Using this does what you want:

find folder -type f -exec gzip -9 {} \; -exec mv {}.gz {} \;

第1 EXEC gzip压缩文件,第二重命名。

The 1st exec gzip the files, the 2nd rename them.

这篇关于Bash脚本:gzip的整个文件夹,并保持文件扩展名相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆