如何将所有子目录中的所有文件gzip压缩为bash中的一个压缩文件 [英] How to gzip all files in all sub-directories into one compressed file in bash

查看:115
本文介绍了如何将所有子目录中的所有文件gzip压缩为bash中的一个压缩文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
将一组目录压缩并创建tar压缩文件

Possible Duplicate:
gzipping up a set of directories and creating a tar compressed file

这篇文章描述如何在目录结构中分别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中的一个压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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