Bash script: Gzip an entire folder and keep files extensions same [closed]

匿名 (未验证) 提交于 2019-12-03 09:18:39

问题:

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

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.

回答1:

Using this does what you want:

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

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!