Shell Script : Join small gzipped files into larger files without unzipping them
2013-11-28 14:00
411 查看
I have some 8000 gz files of around 60MB each. I want to merge them into few larger files. So how to do it in a bash scriptwithout unzipping them ? Shell script may take input as new-file-size or number of files to combine. For example say I have 1.gz, 2.gz, 3.gz ... 10.gzNow I need one file per say 3 files, so now 1.gz, 2.gz and 3.gz will combine into 1_new.gz and so on. |
It is possible to concatinate gziped files together, however when you gunzipthe resulting file you'll get a single stream, see the gzip manual for reference. A script would be similar to Ansgar Wiechers's one for tar: #!/bin/bash maxnum=$1 i=1 j=0 for f in *.gz; do cat $f >> archive_$j.gz i=$((i+1)) if [ $i -eq $maxnum ]; then i=1 j=$((j+1)) fi done Note that the above code is untested. If you want to archive things properly taris a better solution, but if all you want to do is concatinate a number of files which have been gziped then such a concatination as this is good. |
相关文章推荐
- (转)A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'
- ChipScope - For the ChipScope flows, how do you get the signal names into the Analyzer without manually adding them?
- gzjoin -- command to join gzip files into one gzip file
- (极力推荐)BW:How to load and generate a custom hierarchy in SAP Business Warehouse (SAP BW) without using flat files
- How to make the SSIS load infopath XML files into DB?
- Keep the number of files in your /app_code directory small
- upload files in rails with plugin and without plugin
- How to write custom static code analysis rules and integrate them into Visual Studio 2010
- Huge CSV and XML Files in Python, Error: field larger than field limit (131072)
- You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
- Import Data from Txt or CSV files into MYSQL database tables
- LOSF(Lots of small files)存储问题
- How to write custom static code analysis rules and integrate them into Visual Studio 2010
- Combine small files to Sequence file
- You're using the staticfiles app without having set the STATIC_ROOT setting
- insert into table from another table without duplicate
- Huge CSV and XML Files in Python, Error: field larger than field limit (131072)
- Tutorial: Loading Wave files in OpenAL without ALUT
- linq to sql 连接分组 使用join和into
- Linq之详解 From Where Select Group Into OrderBy Let Join