Gzip help

Hi Experts!!

I was creating a zip file in a server which had zip installed in it. I have another server in which zip is not there and i am instructed to make use of gzip to compress files. I would need your help to know the way to create a gzip file.

1) I do the following to create the zip file in my server 1

a) First, i am finding the files that are actually symbolic links
b) Then zip the files to a zip file called files.zip

find . -type l |zip -@r files.zip >$tprefix.ziprun 2>&1

I would like to do the same in my server 2, which makes use of gzip alone.

2) Also, how can we make use of gzip to read the filenames to be zipped from a file x. To make it easier to understand, say abc.txt would contain the files that should be gzipped. Do we have any specific options in gzip that would create the gzip based on the filenames in abc.txt.

Please let me know if you would need any more information. Request all your help..

Thanks in advance :slight_smile:

gzip can only compress, it does not have any way to store multiple files in one archive. Use tar to create an uncompressed archive and gzip to compress that. Most modern tar versions have an option to do this for you.

Thanks very much for your reply.. As suggested, i would first tar the required files and then gzip it.. Can the gzip file be opened in an windows environment.. Generally, we make use of sftp to transfer files from unix to windows.. will that corrupt the gzip file?

Binary files should not be a problem with sftp in my experience.

Winzip and friends can usually handle .tar.gz just fine, some tools might expect a .tgz file extension but in any event, finding free high-quality tools for this should not be hard.

Thanks Era.. can you pls help me out in the method that you suggested with an ex. I am sorry to disturb you much.. I tried the below

I created an empty tar file "touch test.tar " and was trying to append the files to the tar

tar -r test.tar <filename>

wich gave me an error

tar: Options `-Aru' are incompatible with `-f -'
Try `tar --help' for more information.

The tar command-line options are a drag. Use cf to create a new tar and xf to extract. Conventionally you don't have a dash in front, but if you also use some options, you need dashes all over. It's weird and not funny at all.

Don't touch a new file first, just let tar create it on its own.

tar cf file.tar list of files to tar even/with path/names if/you/like
tar xvf file.tar # to extract; v means print while extracting
tar tvf file.tar  # to just print
tar -z -c -v -f file.tar.gz  /home/me # or equivalently tar zxvf file.tar.gz /home/me
tar -C /home/you -c -f file.tar . # -C is only available as an option, so must use dashes throughout
tar jcvf file.tar.bz2 . # older tars don't have this -- use bzip2 instead of gzip

Part of the reason (or at least explanation) is that tar was originally meant for manipulating tape archives, and using it on files is kind of a special case historically.

Hope this helps.