Compress the contents of a directory while copying data into it


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Compress the contents of a directory while copying data into it

Hi guys

I have a need to compress the contents of a directory while I am copying data into it. I was able to do this when it was only one file by doing as below:

STEP1: mknod myfile p

STEP2: chmod 777 myfile

STEP3: compress -v < myfile > myfile.Z &

STEP4: cp -p xyz_file myfile

STEP5: rm myfile

But now my requirement is to have multiple files copied into a directory and compress while the copying is happening so that I dont use a lot of space. Can anyone of you give me some idea of how I can achieve this. For example I want to copy the contents of a directory called source (has file1, file2, file3 and file4) to backup.

Thanks in advance.

Regards

RB
# 2  
How about...
Quote:
for f in *
do
mknod ${f}_pipe p
chmod 777 ${f}_pipe
compress -v < ${f}_pipe > ${f}.Z &
cp -p $f ${f}_pipe
rm ${f}_pipe
done
# 3  
Thanks Jerry

But my requirement is to compress the entire directory and not individual files. Although compressing individual files does the job, I will have to make several changes to already existing procedures and scripts for restoring data from the backups, if need arise.

Again thanks for your reply.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Copying Contents of a file
2metal4u
Hello all. Is there a command to copy the contents of one file into another file as the first line?... UNIX for Beginners Questions & Answers
1
UNIX for Beginners Questions & Answers
How do I compress all files in a directory?
Brittany
the problem states "Write a script that compresses all the files in the directory. Make a directory and put some files in it. Also make a sub directory in your directory and put files in it also. Once you have this basic ability to compress all files within a directory, add to your script a menu of...... UNIX for Dummies Questions & Answers
1
UNIX for Dummies Questions & Answers
Help with searching for a file in a directory and copying the contents of that file in a new file
zel2zel
Hi guys, I am a newbie here :wall: I need a script that can search for a file in a directory and copy the contents of that file in a new file. Please help me. :confused: Thanks in advance~... UNIX for Dummies Questions & Answers
6
UNIX for Dummies Questions & Answers
compress Directory
deep_kol
Hi Friends, I have a directory under which 10 more directories are there. In each 10 directories there are several files. I want to do FTP. But in FTP we cannt Transfer the main directory. each Time we have to go to the respective directry and then we have to to FTP. For this instance I...... Shell Programming and Scripting
9
Shell Programming and Scripting
How to compress a directory on a Sun Solaris 5.7 ?
sameerdes
Hi, Is there any utility to compress an entire directory on a Sun Solaris 5.7 ? Something like "compressdir" on other flavours of Unix ? Thanks... UNIX for Dummies Questions & Answers
4
UNIX for Dummies Questions & Answers