Tar y Gzip

por | 17 enero, 2007

On the command line

  • To pack tar files, use the following commands:
    • for an uncompressed tar file:
      tar -cf packed_files.tar file_to_pack1 file_to_pack2 ...
    • to pack and compress (one step at a time):
      tar -cf packed_files.tar file_to_pack1 file_to_pack2 ...
      gzip packed_files.tar
    • to pack and compress all at once:
      tar -cf - file_to_pack1 file_to_pack2 ... | gzip -c > packed_files.tar.gz
    • to create a tar from a directory and its subdirectories:
      tar -cvf packed_files.tar dir_to_pack
  • To unpack tar files, use the following commands:
    • for an uncompressed tar file:
    tar -xvf file_to_unpack.tar
    • to decompress and unpack one step at a time:
      gunzip packed_files.tar.gz
      tar -xf packed_files.tar
    • to decompress and unpack all at once:
      gunzip -c packed_files.tar.gz | tar -xf -
  • To list the contents of a tar file, use the following command:
    tar -tvf file_to_list.tar

To use bzip2 instead of gzip, simply replace the commands above with bzip2 where gzip is used and bunzip2 where gunzip is used.