Compress the contents of a directory while copying data into it

Tags
compress, directory, shell scripts

 
Thread Tools Search this Thread
# 1  
Old 01-12-2009
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  
Old 01-12-2009
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  
Old 01-12-2009
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.

|
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 UNIX for Beginners Questions & Answers 1 04-28-2018 02:42 AM
How do I compress all files in a directory? Brittany UNIX for Dummies Questions & Answers 1 04-09-2014 12:28 PM
script to compress files in directory that changes its name every day fretagi Shell Programming and Scripting 5 03-28-2012 11:54 AM
compress the data and append into a text file kmanivan82 Shell Programming and Scripting 1 03-19-2012 09:33 PM
Help with searching for a file in a directory and copying the contents of that file in a new file zel2zel UNIX for Dummies Questions & Answers 6 03-05-2011 01:44 PM
sed command for copying the contents of other file replacing it another file on specifc pattern balrajg Shell Programming and Scripting 0 01-26-2011 10:42 PM
Archive directory script with tar/compress AIXfrog Shell Programming and Scripting 7 06-30-2010 09:12 AM
Copying subdirectories of a directory to some other directory and renaming them sholay Shell Programming and Scripting 8 06-29-2010 08:28 PM
Issue: Compress in unix server and FTP to windows and open the compress file using Winzip sakthifire UNIX for Dummies Questions & Answers 4 11-02-2009 09:38 AM
Copying files to a directory #moveon Shell Programming and Scripting 2 04-23-2009 02:33 PM
Remove contents of directory, but not directory pdc Shell Programming and Scripting 9 04-09-2009 03:02 PM
Copying one file at a time from one directory to another directory. Nikhilindurkar UNIX for Dummies Questions & Answers 1 09-01-2008 10:25 AM
compress Directory deep_kol Shell Programming and Scripting 9 11-30-2007 12:12 AM
How to Compress files before moving them in a directory godalle Shell Programming and Scripting 3 11-10-2005 11:59 AM
How to compress a directory on a Sun Solaris 5.7 ? sameerdes UNIX for Dummies Questions & Answers 4 08-23-2003 01:44 AM