Chinaunix首页 | 论坛 | 博客
  • 博客访问: 716164
  • 博文数量: 235
  • 博客积分: 4309
  • 博客等级: 中校
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-17 11:25
个人简介

If you don\\\\\\\\\\\\\\\'t wanna do it, you find an EXCUSE; if you do, you\\\\\\\\\\\\\\\'ll find a WAY :-)

文章分类

全部博文(235)

文章存档

2014年(3)

2013年(2)

2012年(31)

2011年(199)

分类: LINUX

2011-02-19 18:08:52

1.Tar

1.1. 打包档案文件
[root@rhel5 ~]# tar cvf ~/doc.tar doc  →→ 打包 doc目录里全部档案文件到doc.tar

1.2. 查看归档文件

[root@rhel5 ~]# tar tf doc.tar  →→ 查看归档文件里档案清单 
[root@rhel5 ~]# tar tvf doc.tar  →→ 查看归档文件里详细的档案清单

1.3. 打包并压缩档案文件
z -for gzip  compression
j -for bzip2  compression

[root@rhel5 ~]# tar cvfj  doc.tar.bz2 doc →→ 建立一个归档文件 并且 使用bzip2 进行压缩 
[root@rhel5 ~]# tar cvfz  doc.tar.gz doc →→ 建立一个归档文件 并且 使用gzip 进行压缩

1.4. 解压归档文件
[root@rhel5 ~]# tar xvf doc.tar  →→ 解压归档文件 

[root@rhel5 ~]# tar xzvf doc.tar.gz  -C test/ →→ 解压gz归档文件到指定目录 

[root@rhel5 ~]# tar xzvf doc.tar.gz hello.txt  →→ 解压gz归档文件中的指定文件 


1.5. 追加文件

[root@rhel5 ~]# tar -rf  doc.tar ubuntu.png  →→ 向归档文件中追加文件

 

1.6.1 zip

[root@rhel5 ~]# zip -P 123 hello.zip hello.txt→→使用 zip 进行压缩, 密码:123

[root@rhel5 ~]# unzip -P 123 hello.zip →→使用 unzip 进行解压缩, 密码:123

[root@rhel5 ~]# unzip -l iptables.zip →→使用 unzip 查看压缩包内文件

[root@rhel5 ~]# zip -d iptables.zip bbs.txt →→使用 zip 删除压缩包内指定文件


2.gzip, gunzip

一般配合Tar命令使用
[root@rhel5 ~]# gzip ./doc/about.txt  →→ 使用 gzip 进行压缩, 并且不保留源文件(亦即:将源文件更改为压缩档) 
[root@rhel5 ~]# gunzip ./doc/about.gz  →→ 使用 gzip 进行解压缩

[root@rhel5 ~]# 等同于 gzip -d ./doc/about.gz


[root@rhel5 ~]# gzip -9 -vc ./doc/about.txt > ./doc/about.gz  →→ 使用 gzip 进行压缩(使用最高压缩比), 并且保留源文件
[root@rhel5 ~]# bzip2 -9 -vc ./doc/about.txt > ./doc/about.bz2  →→ 使用 bzip2 进行压缩(使用最高压缩比), 并且保留源文件

更简单的方法:gzip -9 -v <./doc/about.txt>./doc/about.gz (同样保留源文件)


3. bzip2, bunzip2 (压缩比 较之gzip 会稍高)
用法可类比gzip,gunzip

-----------------------------------------------------------------------------------


END TIPS:

split( uptime who chsh chfn finger last )

1.拆分
[root@localhost ~]# split -b 4m myfile.img myfileSp→→  注:分拆为大小为4M的文件;
[root@localhost ~]# ls -lh myfileSp* →→ 注:列出分拆文件,我们看到有两个文件;
-rw-r--r-- 1 root root 4.0M 04-27 20:37 myfileSpaa
-rw-r--r-- 1 root root 3.9M 04-27 20:37 myfileSpab

2.合并
[root@localhost ~]# cat myfileSp* > newmyfile.img→→  注:我们尝试合并文件到一个新文件中;
[root@localhost ~]# ls -lh newmyfile.img
-rw-r--r-- 1 root root 7.9M 04-27 20:38 newmyfile.img
3.验证完整性

[root@localhost ~]# md5sum newmyfile.img myfile.img
7eb24d865a14fa3227633816800522c1 myfile.img
7eb24d865a14fa3227633816800522c1 newmyfile.img

[root@localhost ~]# cksum file

→→ 注:我们对比合并后文件和原文件的MD5值,如果M55值相同,就是完整的;

阅读(372) | 评论(0) | 转发(0) |
0

上一篇:Kill pidof top pstree

下一篇:useful commads

给主人留下些什么吧!~~