Tuesday March 20, 2007
Zip and unzip files on Solaris
The standard way to archive and add/extract files on Solaris is by using the tar commmand. Type
$ tar cvf filename.tar *.c
to put all files ending with extension .c in your directory in one image. The options “c” is for create,”v” for verbose(all the files that were tarred are listed) and “f” is for file. If filename.tar already exists, it is overwritten by default. Refer to the man pages for more details.
To untar the files,type
$ tar xvf filename.tar
where “x” is for extraction.
Note that tar does not compress files.
Gzip is a GNU utility that compresses files using Lempel-Zviv coding.Gunzip extracts all files that have extensions .gz, -gz, .z, -z and .Z. Gunzip also recognizes files with extension .tgz (equivalent to .tar.gz) and .taz (same as .tar.Z). Gzip and gunzip are the same program and you can use gzip to unzip files by using the -d option. The -d option 'forces' gzip to decompress the files. Hence
$gzip -d filename.gz
is the same as
$gunzip filename.gz
A good way to send a bunch of files across the network is to first tar the files and compress them using gzip. For example,
$ tar cf foo.tar filename1 filename2 *.c *.h |gzip -f foo.tar
will compress foo.tar and result in foo.tar.gz in your directory. Note that foo.tar does not appear in your directory as it was piped to the gzip command.
The files can be extracted by by piping the output of gunzip to the tar command .For example,
$gunzip foo.tar.gz |tar -xvf
will unzip and untar foo.tar.gz . This can be done with bzip2 command also.To unzip the files to a different directory ,take a look at this example on BigAdmin.
The environment variable GZIP can hold a set of default options for gzip. For example
GZIP="-8v --name"; export GZIP (for KornShell sh)
setenv GZIP "-8v --name" (for C-Shell (csh))
These options can be overwritten by explicit command line parameters.
Bzip2 is another file compression utility on Solaris that is used to compress files using the Burrows-Wheeler block sorting text compression algorithm and Huffman coding.The compressed files have the extension bz2.
Bunzip2 decompresses all specified files that were compressed using bzip2. Bzip2 and bunzip2 will not , by default, overwrite existing files. Many of the options that are used with gzip and gunzip are also valid for bzip2 and bunzip2.
Posted at 02:49PM Mar 20, 2007 by Jyothi Srinath in Sun | Comments[10]
| « October 2009 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
| Today | ||||||
Today's Page Hits: 121
Posted by Dennis on March 20, 2007 at 06:48 PM PDT #
Posted by Britto I on April 11, 2007 at 10:08 PM PDT #
Posted by Jyothi Srinath on April 17, 2007 at 09:49 AM PDT #
this untar command is very usefull for me. I really appreciate your help here. thanks a lot.
Sur
Posted by Surender Singh on October 18, 2007 at 09:07 PM PDT #
Surender,
Good to know you found the blog useful.Thanks.
Posted by Jyothi on October 23, 2007 at 11:22 AM PDT #
Hi
Can u tell me how to zip a directory in Sun Solaris without changing it to tar file?
Posted by sandeep on March 05, 2008 at 05:31 AM PST #
Sandeep,
I don't think it is possible to zip several files (or a directory) without converting it to a tar file first.The gzip home page , http://gzip.org confirms this.
Posted by Jyothi on March 10, 2008 at 01:40 PM PDT #
Nice info.
Posted by Periyasamy on June 14, 2008 at 07:37 PM PDT #
Periyasamy,
Good to know you found the blog useful. Thanks.
Posted by Jyothi on June 17, 2008 at 03:47 AM PDT #
http://www.batterylaptoppower.com/samsung/pb5nc6b.php Battery For Samsung NP-Q35 Q35 Q45 Q70 AA-PB5NC6B laptop battery ,
http://www.batterylaptoppower.com/samsung/ssb-p30ls.php NEW Battery for SAMSUNG P30 P35 SSB-P30LS SSB-P30LS C laptop battery ,
http://www.batterylaptoppower.com/samsung/np-x1.php Battery for Samsung AA-PB0NC4B E NP-X1-C003 SHK 4800mAh laptop battery ,
Posted by laptop batteries on November 05, 2008 at 08:02 PM PST #