Chinaunix首页 | 论坛 | 博客
  • 博客访问: 303041
  • 博文数量: 75
  • 博客积分: 4010
  • 博客等级: 上校
  • 技术积分: 775
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-18 22:18
文章分类

全部博文(75)

文章存档

2015年(2)

2014年(1)

2007年(8)

2006年(60)

2005年(4)

我的朋友

分类: LINUX

2006-06-25 08:38:27

Resolution:
The tar command is useful for bundling up multiple files and/or directories. In a sense, it's similar to the zip command. However, zip files are compressed by definition; tar files can be compressed, but don't have to be.

For example, in my home directory I have a file called blank.txt and a directory called stuff. To bundle those two up in a file called bundle.tar without compression you can execute:
tar cvf bundle.tar blank.txt stuff/
The convention is tar [options] filename1 [ filename2, ... filenameN ] directory1 [ directory2, ...directoryN ]. After the archive is created, you can transfer bundle.tar conveniently. Now you want to extract the bundle.tar archive. You can execute:
tar xvf bundle.tar
and you'll get a file called blank.txt and a directory called stuff in your current working directory.

When file size is a concern, adding compression is easy. To have your tar file automatically gzipped, instead of the creating the bundle.tar as above, you can use:
tar czvf bundle.tar.gz blank.txt stuff/
We add 'z' to the tar options and also append '.gz' onto the archive name for convention. To extract a compressed archive, do:
tar xzvf bundle.tar.gz
The tar command knows about another compression algorithm called bzip2. To use bzip2 instead of gzip, replace the 'z' in the previous two commands with a 'j' For example:
tar cjvf bundle.tar.bz2 blank.txt stuff/
tar xjvf bundle.tar.bz2
The tar man pages are an excellent resource for more information about the advanced options of the tar command, type man tar from the command line.
阅读(840) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~