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

compress -c a1.cpp > a1.cpp.z

thanks a lot,
but how can I do include the recursive option to the above command?

I think you are looking for something like this:

#! /bin/ksh

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

Regards,
Tayyab

thanks, thats what I wanted! :slight_smile: