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

How about...

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.