tar命令--数据归档(二)


tar -cf all.tar *.jpg
这条命令是将所有.jpg的文件打成一个名为all.tar的包。-c是表示产生新的包,-f指定包的文件名。 tar -rf all.tar *.gif
这条命令是将所有.gif的文件增加到all.tar的包里面去。-r是表示增加文件的意思。 tar -uf all.tar logo.gif
这条命令是更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。 tar -tf all.tar
这条命令是列出all.tar包中所有文件,-t是列出文件的意思 tar -xf all.tar
这条命令是解出all.tar包中所有文件,-x是解开的意思
如:
root@d001:~# tar -cvf centos.tar /home/centos
tar: 从成员名中删除开头的“/”
/home/centos/
/home/centos/.bash_logout
/home/centos/.bash_profile
/home/centos/.bashrc
/home/centos/.bash_history
/home/centos/jdk-8u144-linux-x64.tar.gz
/home/centos/.oracle_jre_usage/
/home/centos/.oracle_jre_usage/7e61647adaca41a2.timestamp
/home/centos/.ssh/
/home/centos/.ssh/known_hosts
/home/centos/.ssh/id_rsa
/home/centos/.ssh/id_rsa.pub
/home/centos/.ssh/authorized_keys
/home/centos/mysql-community-libs-5.6.-.el7.x86_64.rpm
/home/centos/mysql-community-release-el7-.noarch.rpm
/home/centos/cloudera-manager-centos7-cm5..0_x86_64.tar.gz
/home/centos/mysql-connector-java-5.1..jar
/home/centos/mysql/
/home/centos/mysql/mysql-community-client-5.6.-.el7.x86_64.rpm
/home/centos/mysql/mysql-community-common-5.6.-.el7.x86_64.rpm
/home/centos/mysql/mysql-community-libs-5.6.-.el7.x86_64.rpm
/home/centos/mysql/mysql-community-server-5.6.-.el7.x86_64.rpm
/home/centos/mysql/perl-5.16.-.el7.x86_64.rpm
/home/centos/mysql/perl-Carp-1.26-.el7.noarch.rpm
/home/centos/mysql/perl-Compress-Raw-Bzip2-2.061-.el7.x86_64.rpm
/home/centos/mysql/perl-Compress-Raw-Zlib-2.061-.el7.x86_64.rpm
/home/centos/mysql/perl-constant-1.27-.el7.noarch.rpm
/home/centos/mysql/perl-Data-Dumper-2.145-.el7.x86_64.rpm
/home/centos/mysql/perl-DBI-1.627-.el7.x86_64.rpm
/home/centos/mysql/perl-Encode-2.51-.el7.x86_64.rpm
/home/centos/mysql/perl-Exporter-5.68-.el7.noarch.rpm
/home/centos/mysql/perl-File-Path-2.09-.el7.noarch.rpm
/home/centos/mysql/perl-File-Temp-0.23.-.el7.noarch.rpm
/home/centos/mysql/perl-Filter-1.49-.el7.x86_64.rpm
/home/centos/mysql/perl-Getopt-Long-2.40-.el7.noarch.rpm
/home/centos/mysql/perl-HTTP-Tiny-0.033-.el7.noarch.rpm
/home/centos/mysql/perl-IO-Compress-2.061-.el7.noarch.rpm
/home/centos/mysql/perl-libs-5.16.-.el7.x86_64.rpm
/home/centos/mysql/perl-macros-5.16.-.el7.x86_64.rpm
/home/centos/mysql/perl-Net-Daemon-0.48-.el7.noarch.rpm
/home/centos/mysql/perl-parent-0.225-.el7.noarch.rpm
/home/centos/mysql/perl-PathTools-3.40-.el7.x86_64.rpm
/home/centos/mysql/perl-PlRPC-0.2020-.el7.noarch.rpm
/home/centos/mysql/perl-Pod-Escapes-1.04-.el7.noarch.rpm
/home/centos/mysql/perl-Pod-Perldoc-3.20-.el7.noarch.rpm
/home/centos/mysql/perl-Pod-Simple-3.28-.el7.noarch.rpm
/home/centos/mysql/perl-Pod-Usage-1.63-.el7.noarch.rpm
/home/centos/mysql/perl-podlators-2.5.-.el7.noarch.rpm
/home/centos/mysql/perl-Scalar-List-Utils-1.27-.el7.x86_64.rpm
/home/centos/mysql/perl-Socket-2.010-.el7.x86_64.rpm
/home/centos/mysql/perl-Storable-2.45-.el7.x86_64.rpm
/home/centos/mysql/perl-Text-ParseWords-3.29-.el7.noarch.rpm
/home/centos/mysql/perl-threads-1.87-.el7.x86_64.rpm
/home/centos/mysql/perl-threads-shared-1.43-.el7.x86_64.rpm
/home/centos/mysql/perl-Time-HiRes-1.9725-.el7.x86_64.rpm
/home/centos/mysql/perl-Time-Local-1.2300-.el7.noarch.rpm
root@d001:~# cd /home/centos/
root@d001:~# tar -tf centos.tar
home/centos/
home/centos/.bash_logout
home/centos/.bash_profile
home/centos/.bashrc
home/centos/.bash_history
home/centos/jdk-8u144-linux-x64.tar.gz
home/centos/.oracle_jre_usage/
home/centos/.oracle_jre_usage/7e61647adaca41a2.timestamp
home/centos/.ssh/
home/centos/.ssh/known_hosts
home/centos/.ssh/id_rsa
home/centos/.ssh/id_rsa.pub
home/centos/.ssh/authorized_keys
home/centos/mysql-community-libs-5.6.-.el7.x86_64.rpm
home/centos/mysql-community-release-el7-.noarch.rpm
home/centos/cloudera-manager-centos7-cm5..0_x86_64.tar.gz
home/centos/mysql-connector-java-5.1..jar
home/centos/mysql/
home/centos/mysql/mysql-community-client-5.6.-.el7.x86_64.rpm
home/centos/mysql/mysql-community-common-5.6.-.el7.x86_64.rpm
home/centos/mysql/mysql-community-libs-5.6.-.el7.x86_64.rpm
home/centos/mysql/mysql-community-server-5.6.-.el7.x86_64.rpm
home/centos/mysql/perl-5.16.-.el7.x86_64.rpm
home/centos/mysql/perl-Carp-1.26-.el7.noarch.rpm
home/centos/mysql/perl-Compress-Raw-Bzip2-2.061-.el7.x86_64.rpm
home/centos/mysql/perl-Compress-Raw-Zlib-2.061-.el7.x86_64.rpm
home/centos/mysql/perl-constant-1.27-.el7.noarch.rpm
home/centos/mysql/perl-Data-Dumper-2.145-.el7.x86_64.rpm
home/centos/mysql/perl-DBI-1.627-.el7.x86_64.rpm
home/centos/mysql/perl-Encode-2.51-.el7.x86_64.rpm
home/centos/mysql/perl-Exporter-5.68-.el7.noarch.rpm
home/centos/mysql/perl-File-Path-2.09-.el7.noarch.rpm
home/centos/mysql/perl-File-Temp-0.23.-.el7.noarch.rpm
home/centos/mysql/perl-Filter-1.49-.el7.x86_64.rpm
home/centos/mysql/perl-Getopt-Long-2.40-.el7.noarch.rpm
home/centos/mysql/perl-HTTP-Tiny-0.033-.el7.noarch.rpm
home/centos/mysql/perl-IO-Compress-2.061-.el7.noarch.rpm
home/centos/mysql/perl-libs-5.16.-.el7.x86_64.rpm
home/centos/mysql/perl-macros-5.16.-.el7.x86_64.rpm
home/centos/mysql/perl-Net-Daemon-0.48-.el7.noarch.rpm
home/centos/mysql/perl-parent-0.225-.el7.noarch.rpm
home/centos/mysql/perl-PathTools-3.40-.el7.x86_64.rpm
home/centos/mysql/perl-PlRPC-0.2020-.el7.noarch.rpm
home/centos/mysql/perl-Pod-Escapes-1.04-.el7.noarch.rpm
home/centos/mysql/perl-Pod-Perldoc-3.20-.el7.noarch.rpm
home/centos/mysql/perl-Pod-Simple-3.28-.el7.noarch.rpm
home/centos/mysql/perl-Pod-Usage-1.63-.el7.noarch.rpm
home/centos/mysql/perl-podlators-2.5.-.el7.noarch.rpm
home/centos/mysql/perl-Scalar-List-Utils-1.27-.el7.x86_64.rpm
home/centos/mysql/perl-Socket-2.010-.el7.x86_64.rpm
home/centos/mysql/perl-Storable-2.45-.el7.x86_64.rpm
home/centos/mysql/perl-Text-ParseWords-3.29-.el7.noarch.rpm
home/centos/mysql/perl-threads-1.87-.el7.x86_64.rpm
home/centos/mysql/perl-threads-shared-1.43-.el7.x86_64.rpm
home/centos/mysql/perl-Time-HiRes-1.9725-.el7.x86_64.rpm
home/centos/mysql/perl-Time-Local-1.2300-.el7.noarch.rpm
tar提供了一种特殊的功能。这就是tar可以在打包或解包的同时调用其它的压缩程序,比如调用gzip、bzip2等。
1) tar调用gzip
gzip是GNU组织开发的一个压缩程序,.gz结尾的文件就是gzip压缩的结果。与gzip相对的解压程序是gunzip。tar中使用-z这个参数来调用gzip。
下面来举例说明一下:
将所有.jpg的文件打成一个tar包,并且将其用gzip压缩,生成一个gzip压缩过的包,包名为all.tar.gz
tar -czf all.tar.gz *.jpg 将上面产生的包解开。
tar -xzf all.tar.gz
2) tar调用bzip2
bzip2是一个压缩能力更强的压缩程序,.bz2结尾的文件就是bzip2压缩的结果。与bzip2相对的解压程序是bunzip2。tar中使用-j这个参数来调用gzip。
下面来举例说明一下:
将所有.jpg的文件打成一个tar包,并且将其用bzip2压缩,生成一个bzip2压缩过的包,包名为all.tar.bz2
tar -cjf all.tar.bz2 *.jpg 将上面产生的包解开
tar -xjf all.tar.bz2
3)tar调用compress
compress也是一个压缩程序,但是好象使用compress的人不如gzip和bzip2的人多。.Z结尾的文件就是bzip2压缩的结果。与 compress相对的解压程序是uncompress。tar中使用-Z这个参数来调用gzip。
下面来举例说明一下:
将所有.jpg的文件打成一个tar包,并且将其用compress压缩,生成一个uncompress压缩过的包,包名为all.tar.Z tar -cZf all.tar.Z *.jpg 将上面产生的包解开 tar -xZf all.tar.Z
tar命令--数据归档(二)的更多相关文章
- tar命令--数据归档(一)
虽然zip命令能够很好的将数据压缩和归档到单个文件,蛋挞不是linux 和unix的标准归档工具. ta命令最开始是用来将文件写到磁盘设备上的归档.然而他也能把输出写道文件里. 你会发现这个可选参数是 ...
- tar命令--数据解档(三)解压.tar.gz文件报错 gzip:stdin:not in gzip format
毕竟是生产..... 提示以下信息: gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not ...
- Linux数据归档和解压缩tar,cpio,gzip,bzip,lzma,zip命令使用
转载:http://www.1987.name/659.html 数据压缩归档和备份是系统管理的日常工作,定期备份不可小视,归档和压缩对于系统管理员或是普通用户来说都经常用到的操作,有很多中压缩格式, ...
- Linux tar命令高级用法——备份数据
Linux tar命令高级用法——备份数据 2015-12-31 Linux学习 Linux上有功能强大的tar命令,tar最初是为了制作磁带备份(tape archive)而设计的,它的作用是把文件 ...
- linux下用tar命令将当前目录下文件按子目录压缩归档
作者:iamlaosong 日常工作中,我们常常需要用tar命令将历史文件压缩归档,再删除源文件,以便节省空间.如果压缩归档成一个文件,就比较简单,用一条命令即可,如命令:tar -czf bak20 ...
- 压缩归档tar命令
归档有两个命令,一个是tar命令,一个是cpio 归档不删除原文件 tar命令语法: tar cvf aa.tar file1 file2 file3 file4 file5 # tar cvf bb ...
- Linux学习笔记二:tar命令使用
tar命令详解 tar命令详解 -c: 建立压缩档案 -x:解压 -t:查看内容 -r:向压缩归档文件末尾追加文件 -u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的 ...
- linux下tar命令详解
linux下tar命令详解 tar是Linux环境下最常用的备份工具之一.tar(tap archive)原意为操作磁带文件,但基于Linux的文件操作机制,同样也可适用于普通的磁盘文件.ta ...
- linux运维中的命令梳理(二)
回想起来,从事linux运维工作已近5年之久了,日常工作中会用到很多常规命令,之前简单罗列了一些命令:http://www.cnblogs.com/kevingrace/p/5985486.html今 ...
随机推荐
- SO BAPI SD_SALESDOCUMENT_CREATE
DATA: E_ORDER_HEADER_IN LIKE BAPISDHD1 OCCURS 0 WITH HEADER LINE, E_ORDER_PARTNERS LIK ...
- JS实战篇
实现选项卡的选择: 效果图如下: 代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8& ...
- etcd节点扩容至两个节点
本篇已经安装了单个etcd,然后进行扩容etcd节点至2个,安装单节点请参照:https://www.cnblogs.com/effortsing/p/10295261.html 实验架构 test1 ...
- nginx报错:nginx: [emerg] unknown directive in /etc/nginx/conf.d/test.conf:4
nginx报错:nginx: [emerg] unknown directive in /etc/nginx/conf.d/test.conf:4 解决: 第四行出现了 tab 空格 , 换成正常的 ...
- cocos2dx基础篇(24) 场景切换效果CCTransitionScene
[3.x] (1)去掉 "CC" (2)卡牌翻转 TransitionFlip 中的样式 tOrientation // //1: kCCTransitionOri ...
- BeautifulSoup解析豆瓣即将上映的电影信息
工欲善其事,必先利其器,我们首先得了解beautifulsoup的使用,这其实是一个比较简单的东西 BeautifulSoup的基本使用语法规则 .find() 使用示例 soup.find('a ...
- 【miscellaneous】北斗短报文
北斗系统最大的特色在于有源定位和短报文特色服务,不止解决了中国有无卫星导航系统的问题,还能将短信和导航结合,是中国北斗卫星导航系统的独特发明,也是一大优势. 北斗的短报文功能,在国防.民生和应急救援等 ...
- leveldb Arena
背景我们都知道,对于一个高性能的服务器端程序来说,内存的使用非常重要.C++提供了new/delete来管理内存的申请和释放,但是对于小对象来说,直接使用new/delete代价比较大,要付出额外的空 ...
- etcd集群添加节点
查看当前集群节点信息 # etcdctl member list --write-out=table +------------------+---------+------------------- ...
- linux中/etc/profile 和 ~/.bash_profile 的区别
在 linux中设置环境变量一般使用bash_profile进行配置 其中/etc/bash_profile 表示系统整体设置 ,生效后系统内所有用户可用而 ~/.bash_profile 只表示当前 ...