Compress dan Dicompress directory

Februari 27, 2007 at 12:42 pm (Networking)

Compress dan Decompress File dengan TAR di FreeBSD

 

1. COMPRESS FILEContoh apabila terdapat direktori gallery/

|wus@bsd:~/coba> ls -la
total 3
drwxr-xr-x 3 wus wheel 512 Jul 30 08:45 .
drwxr-xr-x 10 wus wheel 1024 Jul 30 08:44 ..
drwxr-xr-x 3 wus wheel 512 Jul 30 08:42 gallery


Compress direktori gallery/ beserta sub-direktorinya menjadi file *.tar

|wus@bsd:~/coba> tar cvf photo.tar gallery/
gallery/
gallery/titi-kamal-2.jpg
gallery/titi-kamal-3.jpg
gallery/titi-kamal-1.jpg
gallery/privat/
gallery/privat/ria.jpg
|wus@bsd:~/coba> ls -la
total 187
drwxr-xr-x 3 wus wheel 512 Jul 30 08:48 .
drwxr-xr-x 10 wus wheel 1024 Jul 30 08:44 ..
drwxr-xr-x 3 wus wheel 512 Jul 30 08:42 gallery
-rw-r–r– 1 wus wheel 174080 Jul 30 08:47 photo.tar

Compress direktori gallery/ beserta sub-direktorinya menjadi file *.tar.Z

|wus@bsd:~/coba> tar cvZf photo.tar.Z gallery/
gallery/
gallery/titi-kamal-2.jpg
gallery/titi-kamal-3.jpg
gallery/titi-kamal-1.jpg
gallery/privat/
gallery/privat/ria.jpg
|wus@bsd:~/coba> ls -la
total 411
drwxr-xr-x 3 wus wheel 512 Jul 30 08:48 .
drwxr-xr-x 10 wus wheel 1024 Jul 30 08:44 ..
drwxr-xr-x 3 wus wheel 512 Jul 30 08:42 gallery
-rw-r–r– 1 wus wheel 174080 Jul 30 08:47 photo.tar
-rw-r–r– 1 wus wheel 217985 Jul 30 08:48 photo.tar.Z

Compress direktori gallery/ beserta sub-direktorinya menjadi file *.tar.gz

|wus@bsd:~/coba> tar cvzf photo.tar.gz gallery/
gallery/
gallery/titi-kamal-2.jpg
gallery/titi-kamal-3.jpg
gallery/titi-kamal-1.jpg
gallery/privat/
gallery/privat/ria.jpg
|wus@bsd:~/coba> ls -la
total 587
drwxr-xr-x 3 wus wheel 512 Jul 30 08:49 .
drwxr-xr-x 10 wus wheel 1024 Jul 30 08:44 ..
drwxr-xr-x 3 wus wheel 512 Jul 30 08:42 gallery
-rw-r–r– 1 wus wheel 174080 Jul 30 08:47 photo.tar
-rw-r–r– 1 wus wheel 217985 Jul 30 08:48 photo.tar.Z
-rw-r–r– 1 wus wheel 164140 Jul 30 08:49 photo.tar.gz
Untuk melihat tipe file-nya gunakan command : [ file file-name ]

|wus@bsd:~/coba> file photo.tar
photo.tar: GNU tar archive
|wus@bsd:~/coba> file photo.tar.Z
photo.tar.Z: compress’d data 16 bits

|wus@bsd:~/coba> file photo.tar.gz
photo.tar.gz: gzip compressed data, deflated, last modified: Tue Jul 30 08:49:51 2002, os: Unix

Dan untuk mengetahui ukuran file/direktori digunakan : [ du -h file/dir-name ]

|wus@bsd:~/coba> du -h gallery/
76k gallery/privat
167k gallery
|wus@bsd:~/coba> du -h photo.tar
184k photo.tar

|wus@bsd:~/coba> du -h photo.tar.Z
224k photo.tar.Z

|wus@bsd:~/coba> du -h photo.tar.gz
176k photo.tar.gz

2. DECOMPRESS FILE

Decompress file *.tar

|wus@bsd:~/coba> tar xvf photo.tar
gallery/
gallery/titi-kamal-2.jpg
gallery/titi-kamal-3.jpg
gallery/titi-kamal-1.jpg
gallery/privat/
gallery/privat/ria.jpg

Decompress file *.tar.Z

|wus@bsd:~/coba> tar xZvf photo.tar.Z
gallery/
gallery/titi-kamal-2.jpg
gallery/titi-kamal-3.jpg
gallery/titi-kamal-1.jpg
gallery/privat/
gallery/privat/ria.jpg

Decompress file *.tar.gz

|wus@bsd:~/coba> tar xzvf photo.tar.gz
gallery/
gallery/titi-kamal-2.jpg
gallery/titi-kamal-3.jpg
gallery/titi-kamal-1.jpg
gallery/privat/
gallery/privat/ria.jpg

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: