Přejít na menu

Archives and compressing: tar and gzip

Správa článků

Vyhledávání Vyhledávání
28.10.2012 09:57
,
Počet přečtení: 650

Creating and extracting (compressed) archives with tar and gzip programs.

  • gzip program can compress the single file
  • tar program can create the single file from multiple files or folders
  • if you want to pack and compress the directory, you need both of them

Creating archive

tar -zcvf archive.tgz path/to/src/dir/

Gzip is suitable for packing the single files only:

gzip archivefile1.txt # creates the archive and deletes the source file
gzip -c archivefile1.txt > archivefile1.txt.gz # creates the archive and preserves the source file
gzip -r documents_folder # creates separate archives from all files recursively (obviously NOT what you want with your directory!:))

Extracting from archive

tar -zxvf archive.tgz

Or with gunzip:

gunzip archive.tgz

Lists all files in the archive

tar -ztvf archive.tgz

Parameters:

z - gzip type
x - extract the archive
c - create the archive
v - verbose
f - user archive file (= not stdin/stdout)
t - list files in archive

Vytvořil 28. října 2012 v 10:08:38 mira. Upravováno 5x, naposledy 20. ledna 2015 v 07:58:56, mira


Diskuze ke článku

Vložení nového komentáře
*
*
*