问题描述
这篇文章描述如何在目录结构中分别gzip每个文件.但是,我需要做一些稍微不同的事情.我需要为某个目录下的所有文件生成一个大的gzip文件.我还需要能够指定压缩文件的输出文件名(例如,files.gz)并覆盖旧的压缩文件(如果已经存在).
This post describes how to gzip each file individually within a directory structure. However, I need to do something slightly different. I need to produce one big gzip file for all files under a certain directory. I also need to be able to specify the output filename for the compressed file (e.g., files.gz) and overwrite the old compressed file file if one already exists.
推荐答案
tar -zcvf compressFileName.tar.gz folderToCompress
folderToCompress中的所有内容都将进入compressFileName
everything in folderToCompress will go to compressFileName
经过审查和评论,我意识到人们可能会对compressFileName感到困惑,而没有扩展名.如果需要,可以将.tar.gz扩展名(如建议的那样)与compressFileName
After review and comments I realized that people may get confused with compressFileName without an extension. If you want you can use .tar.gz extension(as suggested) with the compressFileName
这篇关于如何将所有子目录中的所有文件gzip压缩为bash中的一个压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!