Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to archive and extract a .tar.gz file

A simple question. On x86 Solaris 10, I tried the following to compress a folder(Data) of files.

tar -cvf /path/to/Data/* | gzip > /path/to/archive/Data.tar.gz

Now, I can list the file names and their sizes using:

gunzip -c Data.tar.gz

However, when I try to uncompress(for validation) Data.tar.gz:

gzip -d Data.tar.gz
tar -xvf Data.tar

I get a "checksum error"

Can someone please suggest the correct way to compress and extract files in Solaris 10. Thanks

like image 269
Shuvo Shams Avatar asked Jan 24 '14 17:01

Shuvo Shams


1 Answers

You can do archive in 2 steps:

$ tar cvf archive.tar file* 
$ gzip archive.tar

(It will create archive.tar.gz, while removing archive.tar.)

Extraction also in 2 steps:

$ gunzip archive.tar.gz

(It will create archive.tar and remove archive.tar.gz.)

$ tar xvf archive.tar

To list files inside the .gz file:

gzip -l archive.tar.gz

Alternatively, you can use 7zip which put together all files as well as compress them.

7z a archive.7z Makefile* (to create archive)
7z l archive.7z           (to list files inside the archive)
7z e archive.7z           (to extract)
like image 59
januarvs Avatar answered Oct 03 '22 14:10

januarvs