Compress a tar file to smaller size


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compress a tar file to smaller size
# 1  
Old 02-09-2014
Question [Solved] Compress a tar file to smaller size

I have a tar file with name DTT012_GP_20140207.tar and many more with different names of different sizes ranging from 1GB to 4GB.
Now my requirement is to extract/not extract these files and then divide it into various parts of size 500MB and save it with different names and then compress it(zip/tar).
(If 1GB tar file, it should divide into 2 500MB,
If 1.6GB file, it should divide into 2 500MB and the remanning 100MB into another)

I have tried this
Code:
split -b 500000000 DTT012_GP_20140207.tar /tmp/newdata/DTT012_GP_20140207_part.tar

The output files generated come with name DTT012_GP_20140207_part.tara , DTT012_GP_20140207_part.tarb , DTT012_GP_20140207_part.tarc

Please let me know if I am doing it right and also how do i name it in increasing order as part1,part2,part3??

Last edited by bartus11; 02-09-2014 at 10:05 AM.. Reason: Please use [code][/code] tags.
# 2  
Old 02-09-2014
tar (tape archive) by default does not compress files. It merely manipulates files in an archive.
This User Gave Thanks to fpmurphy For This Post:
# 3  
Old 02-09-2014
If it was me, and if I understand you correctly, I would simply untar (tar -xvf) the original file (or tar -xvzf if gzipped), and then split it into multiple parts and then tar them up again and recompress (tar -cvzf)
# 4  
Old 02-09-2014
Question

Neo:

Thanks.
But will that serve the purpose??
I want the files from the 1GB tar file (data.tar- untarred to data) to be copied into two separate folders as data_part1 and data_part2 and then recompress these two folders.

Contents inside the tar file are more file1.gz,file2.gz,file3.gz... and so on..

file1.gz,file2.gz (assuming it to be less than or equal to 500MB) should be copied to file1 and then compress to data_part1.zip and then remaining files(file3.gz,file4.gz...) assuming them to total another 500MB and copy to data_part2 and then compress to data_part.zip

Can you or any other Unix expert help me with that??
# 5  
Old 02-09-2014
Well, your second post describes quite a different problem than your first post.

What script have you written?

Our amazing members are not here to write your scripts for you, but to assist you in your (best) efforts to define your problem and write your own scripts.
# 6  
Old 02-09-2014
Neo:

Firstly, my apologies. I dint mean to ask experts here to write a script for me for the above post.

I thought it was a one line thing required.

Anyways, I am trying what i have already mentioned.

Code:
split -b 500000000 DTT012_GP_20140207.tar /tmp/newdata/DTT012_GP_20140207.tar

But with some help around, i tried the below modification,

Code:
split -b 500000000 DTT012_GP_20140207.tar  /tmp/newdata/DTT012_GP_20140207.tar_part_

Output:
Code:
DTT012_GP_20140207.tar_part_aa
DTT012_GP_20140207.tar_part_ab
DTT012_GP_20140207.tar_part_ac

Also, i forgot to mention that once I have split the particular file.tar, I have to resume it as well for which I am using the below.
Code:
cat DTT012_GP_20140207.tar_part_* | tar xzpvf -

Output:
Code:
DTT012_GP_20140207.tar

#Update-It is working fine now.

Thanks a lot Neo.

Last edited by Shaibal_bp; 02-09-2014 at 04:21 PM.. Reason: Detailing
This User Gave Thanks to Shaibal_bp For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Physical disk IO size smaller than fragment block filesystem size ?

Hello, in one default UFS filesystem we have 8K block size (bsize) and 1K fragmentsize (fsize). At this scenary I thought all "FileSytem IO" will be 8K (or greater) but never smaller than the fragment size (1K). If a UFS fragment/blocksize is allwasy several ADJACENTS sectors on disk (in a ... (4 Replies)
Discussion started by: rarino2
4 Replies

2. Shell Programming and Scripting

Script to Compare file size and delete the smaller

I am pretty new to scripting, so I appreciate your advice in advance. The problem: 100 directories each containing 2 files that have the same extension with random names. The only attribute that discriminates the files is size. I would like to write a script that compares the files for size... (6 Replies)
Discussion started by: JC_1
6 Replies

3. UNIX for Dummies Questions & Answers

Compress 1st 20 Large different File using tar

Sorry guys.. dont know where to put this.. currently I am cleaning up system dump on our aix machine and I wanted to set zero the 1st 20 large file but before doing that I wanted to create some backup. is there any command that can compress all these file same time? tar syntax file? ... (2 Replies)
Discussion started by: thermometer
2 Replies

4. Shell Programming and Scripting

identify files with "Normal termination" and compress them into a .tar.gz file

Hi, I have hundreds of files "*.out" located in one folder, and I want to: 1. Identify the good files containing "Normal termination" (grep "Normal termination" *.out ) 2. Compress the good files into a tar.gz file (tar cvfz good.tar.gz *.goog.out ) Is there a way I can automate this... (4 Replies)
Discussion started by: rockytodd
4 Replies

5. Shell Programming and Scripting

tar and compress in one step

I know there is a way to tar up directory and sub-directories and have it compressed all in one command but but the syntax escapes me. I seem to re-call something like this: tar -cvf /tmp/file.tar - | compress ? Can somebody please provide me with the syntax on how to tar/compress and... (6 Replies)
Discussion started by: BeefStu
6 Replies

6. UNIX for Dummies Questions & Answers

Compress the file using Tar command

Hi, When i am tar the file particular ,csv file format in a folder i am receiving the error Command: tar cf New_data.tar /new/file/mari/getdata/small/*.xml Arguements too long But sometimes i am able to compress other folder but the tar folder contains all the file format and... (10 Replies)
Discussion started by: marivinay
10 Replies

7. Shell Programming and Scripting

How to get the size of tar,Z,gz type file.

Hi, How to get the size of the .tar file .Z file .gz file. Please help me what command i need to use in shell scripting :( Regards, Kalai (3 Replies)
Discussion started by: kalpeer
3 Replies

8. UNIX Desktop Questions & Answers

file zip,rar,tar,compress,uncompress,unzip,unrar

i want know how to compress and uncompress file using unix, compress uncompress,zip,unzip,rar,unrar,how its work and more about this.:confused: (1 Reply)
Discussion started by: ismael xavier
1 Replies

9. UNIX for Dummies Questions & Answers

maximum tar file size?

Is there a reasonable maximum limit for tar file sizes? I want to transfer a pile of files from one server to another but have restricted means, so tarring them first will probably be best... but how big can I go - both for the file format itself and for the operating system (linux) to handle? ... (7 Replies)
Discussion started by: Bobby
7 Replies

10. UNIX for Advanced & Expert Users

tar and compress

I need to compress and tar a couple files in a directory, but I also want the original files unchanged, ie if I compress a1.cpp , then a1.cpp becomes a1.cpp.z, but what I want after running the compress utility is to have both a1.cpp as it is and a1.cpp.z and then tar a1.cpp.z to an... (4 Replies)
Discussion started by: muru
4 Replies
Login or Register to Ask a Question