tar and compress


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users tar and compress
# 1  
Old 07-28-2006
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 archive.

I would like to do it without making a copy of all these files into a different directory, since the files sometimes goes upto couple of GB's. So that I dont have any space limitaion.
Any suggestions?

Thanks
Muru
# 2  
Old 07-28-2006
compress -c a1.cpp > a1.cpp.z
# 3  
Old 07-30-2006
thanks a lot,
but how can I do include the recursive option to the above command?
# 4  
Old 07-30-2006
I think you are looking for something like this:
Code:
#! /bin/ksh

for i in `find /yourpath -name *.cpp`; do
compress -c $i > $i.z
done

Regards,
Tayyab
# 5  
Old 07-31-2006
thanks, that works

thanks, thats what I wanted! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (5 Replies)
Discussion started by: Shaibal_bp
5 Replies

2. 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

3. 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

4. Shell Programming and Scripting

Archive directory script with tar/compress

Hi all I need to write a script that archives all files with a certain date in the filename, to another location. It has to run on a AIX using tar/compress or another standard AIX tool. The directory will have x files, each prefixed with a date like yyyymmdd_desc.csv. I need all to... (7 Replies)
Discussion started by: AIXfrog
7 Replies

5. UNIX for Advanced & Expert Users

UNIX: Command to compress folder and all files into a tar

I am trying to grab a folder and all the folders and files underneath it and send it from one computer to another. I basically want to compress the whole folder into a tar, tgz, or zip file so that it can be sent as one file. is there a command to compress a folder and all its contents into a tar... (7 Replies)
Discussion started by: kane4355
7 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 tar, compress and remove files older than two days

Hi, I'm Eddy from Belgium and I've the following problem. I try to write a ksh script in AIX to tar, compress and remove the original *.wav files from the directory belgacom_sf_messages older than two days with the following commands. The problem is that I do not find a good combination... (4 Replies)
Discussion started by: edr
4 Replies

8. Shell Programming and Scripting

compress directories with .tar extension

hi guys.. Since am a bit new to shell scripting, can anyone help me with this problem please.. i've been struggling with it since 2 days. :( I have a directory lets say myFolder and within it I have sub directories let say myFolder1.tar, myFolder2, myFolder3, etc. I need to write a shell... (12 Replies)
Discussion started by: kanexxx
12 Replies

9. Shell Programming and Scripting

Search, Tar and Compress in one line

Hi all, I am supposed to collect a huge amount of log files from a unix system (HP-UX) onto a local system. The log files are not in one place, but they are scattered all over the Unix server. The unix server has only limited space, so that I can not create a tar file first and then compress it.... (4 Replies)
Discussion started by: bluesky099
4 Replies

10. UNIX for Dummies Questions & Answers

tar command with compress option...

Hi ! i have to write a script that archivs homes not used since 3 years. First, my script gathers the users that are concerned, using the following command : ll -lt /home/*/.sh_history | egrep '2000|1999|1998|1997' | awk '{print $3}' i obtain a list like this : user_1 user_2 ...... (3 Replies)
Discussion started by: tomapam
3 Replies
Login or Register to Ask a Question