linux文件解-压缩
常用:
解压tar.gz包 使用命令:tar -zxvf file.tar.gz -z 指有gzip的属性 -x 解开一个压缩文件的参数 -v解压过程中显示文件 -f放最后接filename
解压tar包 使用命令:tar -xvf file.tar
查看tar包里打包了哪些文件: tar -tf file.tar 或tar -tvf file.tar
解压zip文件 使用命令:unzip file.zip AIX下解压ZIP文件: jar -xvf filename.zip
gunzip file.zip
解压rar文件 使用命令:unrar e file.rar 把file.rar中的所有文件解压出来
tar包是未压缩过的,而zip或gz是打包后再进行压缩的文件
打包与压缩
打包目录 使用命令 tar -cvf dir1.tar dir1 -c 是comprise 压缩/打包
打包并压缩 使用命令 tar -zcvf dir1.tar.gz dir1 -z是打包并以gzip压缩
排除某个不想添加到压缩文件的目录: tar -zcvf dir3.tar.gz dir3 --exclude=dir3/dirx/dirr --exclude=dir3/dirx/diry----错误,看最后实例
zip压缩 使用命令 zip -r myfile.zip dirname -r表示递归压缩目录下所有文件
gzip压缩 只压缩文件,不保留源文件,不压缩目录
把project_a文件夹下的文件打包成project.war
1.打包jar - cvf project.war /project_a
-c 创建war包
-v 显示过程信息
-f 指 定 JAR文件名,通常这个参数是必须的
-M 不产生所有项的清单 (MANIFEST〕文件,此参数会忽略 -m参数
-0 这个是阿拉伯数字 ,只打包不压缩的意思
2.解压war包:
jar -xvf project.war
[root@rusky SHARE]# cd testdir3
[root@rusky testdir3]# ls
fuckdir fuck.txt
[root@rusky testdir3]# gzip *
gzip: fuckdir is a directory -- ignored
[root@rusky testdir3]# gzip -r * 有目录,加r递归压缩目录中文件
[root@rusky testdir3]# ls
fuckdir fuck.txt.gz
如果只压缩单个文件,非目录,则:gzip 123.txt 压缩后源文件123.txt变成123.txt.gz
bzip2解压缩:
bzip2是一个压缩能力更强的压缩程序,.bz2结尾的文件就是bzip2压缩的结果。 与bzip2相对的解压程序是bunzip2。tar中使用-j这个参数来调用gzip。下面来举例
说明一下:-j表示有bz2属性
# tar -cjf all.tar.bz2 *.jpg
这条命令是将所有.jpg的文件打成一个tar包,并且将其用bzip2压缩,生成一个bzip2压缩过的包,包名为all.tar.bz2
# tar -xjf all.tar.bz2
这条命令是将上面产生的包解开。
============
AIX解压:.tar.gz格式方式
gunzip testfile.tar.gz 得到:testfile.tar
tar -xvf testfile.tar 得到testfile
=========================
tar压缩目录时排除我们不需要的某个目录或文件:
[root@rusky home]# tree test/ //查看test目录结构
test/
├── test1
│ ├── file1
│ ├── file1.1
│ └── file1.2
├── test2
│ ├── file2-1
│ ├── test2-1
│ └── test2-2
└── test3 5 directories, 4 files
[root@rusky home]# tar -zcvf rusky1.tar.gz test/
test/
test/test1/
test/test1/file1
test/test1/file1.1
test/test1/file1.2
test/test2/
test/test2/test2-1/
test/test2/test2-2/
test/test2/file2-1
test/test3/
[root@rusky home]# tar -zcvf rusky1.tar.gz test/ --exclude=test1 //排除test目录下的test1目录。"="等号后面跟着的是要压缩目录下的某个具体目录名,而不是路径
test/
test/test2/
test/test2/test2-1/
test/test2/test2-2/
test/test2/file2-1
test/test3/
[root@rusky home]# tar -zcvf rusky1.tar.gz test/ --exclude=test1 --exclude=test3 //排除多个test2和test3目录
test/
test/test2/
test/test2/test2-1/
test/test2/test2-2/
test/test2/file2-1
[root@rusky home]# tar -zcvf rusky1.tar.gz test/ --exclude=file* //排除以file开头的所有文件,包括字目录里的
test/
test/test1/
test/test2/
test/test2/test2-1/
test/test2/test2-2/
test/test3/
[root@rusky home]# tar -zcvf rusky1.tar.gz test/ --exclude=/home/test/test1/ --exclude=/home/test/test2/ //exclude后面不能是路径,否则不生效
test/
test/test1/
test/test1/file1
test/test1/file1.1
test/test1/file1.2
test/test2/
test/test2/test2-1/
test/test2/test2-2/
test/test2/file2-1
test/test3/
[root@rusky home]# tar -zcvf rusky1.tar.gz test/ --exclude=/home/test/test1 --exclude=/home/test/test2 //同上,exclude后面跟路径不生效
test/
test/test1/
test/test1/file1
test/test1/file1.1
test/test1/file1.2
test/test2/
test/test2/test2-1/
test/test2/test2-2/
test/test2/file2-1
test/test3/
[root@rusky home]# tar -zcvf rusky1.tar.gz test/ --exclude=./test/test1/ --exclude=./test/test2 //同上,路径不生效,默认压缩全部
test/
test/test1/
test/test1/file1
test/test1/file1.1
test/test1/file1.2
test/test2/
test/test2/test2-1/
test/test2/test2-2/
test/test2/file2-1
test/test3/
[root@rusky home]#
linux文件解-压缩的更多相关文章
- Linux文件打包压缩、解压缩、备份命令使用方法(转载)
对于刚刚接触Linux的人来说,一定会给Linux下一大堆各式各样的文件名给搞晕.别个不说,单单就压缩文件为例,我们知道在Windows下最常见的压缩文件就只有两种,一是,zip,另一个是.rar.可 ...
- Linux - 文件的压缩与归档
文件压缩 常用的压缩命令有 gzip.bzip2 等. gzip 命令 命令格式 gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ] 命令参数 -c ...
- 3.Linux 文件的压缩与打包
1.常用压缩打包命令 常用的压缩打包扩展名为如下: *.Z compress 程序压缩的文件,非常老旧了,不再细说 *.gz gzip 程序压缩的文件: *.bz2 bzip2 程序压缩的文件: *. ...
- shell 命令 文件(解)压缩 tar,zip, gzip,bzip2
1.gzip / gunzip [ gzip data.c] 对文件进行压缩,生成 data.c.gz 同时删除了原文件 同时压缩两个文件 [gunzip data.c.gz ...
- Linux 文件的压缩与解压
1. tar结尾压缩命令 [root@test ~]# tar -cvf grub.tar /boot/grub/ 查看压缩包文件 [root@test ~]# tar -vtf grub.tar ...
- Linux 文件夹压缩命令总结
tar命令 解包:tar zxvf FileName.tar 打包:tar czvf FileName.tar DirName gz命令 解压1:gunzip FileName.gz 解压2:gzip ...
- 把linux文件夹压缩成tar.gz的命令
解压 tar zxvf 文件名.tar.gz 压缩 tar zcvf software.tar.gz /usr/local/software
- linux 文件解压
解压 tar -xvf file.tar //解压 tar包 tar -xzvf file.tar.gz //解压tar.gz tar -xjvf file.tar.bz2 //解压 tar.bz ...
- linux 文件打包压缩成.tar.gz
tar czvf beian.drcluod.cn.20180509.tar.gz ./beian.drcloud.cn/*
随机推荐
- Redhat Enterprise 5.4下安装配置Oracle 11g R2详细过程
1.Linux环境配置准备 环境:Linux:Redhat Enterprise 5.4,DB:Oracle 11g R2 X64,Oracle安装到/home/oralce_11目录下. 配置过程如 ...
- "float: left;" div 不换行显示
<div id='p'> <div id='c1'> </div> <div id='c2'> </div> <div id='c3' ...
- 搭建Struts2开发环境
搭建Struts2环境时,我们一般需要做以下几个步骤的工作: 1.创建javaweb工程 2.找到开发Struts2应用需要使用到的jar文件 3.创建jsp文件 4.创建action文件 5.编写S ...
- oracle where与having
where与having可以过滤,一般来说尽量使用where ,但是如果过滤条件中有组函数,只能使用having SQL> select deptno,avg(sal) from emp gro ...
- IO流(文件字节输入输出
输入输出流可能有不允许操作,可能有出现错误,必须在try语句中进行 FileOutputStream out1=new FileOutputStream("test1.txt") ...
- spark 环境变量系列配置
1. hadoop core-site.xml配置
- MOOTOOLS简单操作应用知识
在项目中我们经常需要用到全选/反选.等操作按钮. 基于mootools框架与jquery框架不一致.导致缓慢. $('chkall').addEvent('click',function(){ if( ...
- PHPCMSv9 更改后台地址(测试)
最新发布的PHPCMS V9由于采用了MVC的设计模式,所以它的后台访问地址是固定的,虽然可以通过修改路由配置文件来实现修改,但每次都修改路由配置文件对于我来说有点麻烦了,而且一不小心就会出错.这里使 ...
- 摇滚吧HTML5!有声前端交互!(一)
生命的伊始,婴儿用明亮的哭声宣告一个新生命的诞生,睁开双眼之前,一双小耳朵已经开始聆听这个世界.在如今的用户体验领域,几乎所有公司都会有视觉设计师,却鲜有注重听觉交互的公司.随着各大厂商对HTML5支 ...
- 转:Linux 内核中的 cdev_alloc和cdev_add
内核中每个字符设备都对应一个 cdev 结构的变量,下面是它的定义:linux-2.6.22/include/linux/cdev.hstruct cdev {struct kobject kobj; ...