linux zip/unzip命令
2016-03-29 17:12
471 查看
unzip命令
主要功能:解压缩zip文件使用方式:
unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
将压缩文件file[.zip]中list列表的文件解压到exdir文件夹下,其中解压缩排除xlist列表的文件[夹]
参数说明
-Z 转换为ZipInfo mode,必须是第一参数-x 解压缩排除xlist列表的
-d 压缩文件解压到exdir文件夹下
opts
-p 将压缩文件显示到屏幕上
-f 更新现有的文件
-u 与-f参数类似,但是除了更新现有的文件外,也会将压缩文件中 的其他文件解压缩到目录中
-v 显示执行过程
-l 显示压缩包里含有的文件
-t 测试压缩文件是否损坏
-z 显示压缩文件的备注信息
-T 更新压缩文件修改时间为当前时间
modifiers
-n 解压缩不覆盖原文件
-o 强制覆盖原文件
-j 不处理压缩文件原有路径
-q 执行时不显示信息
-M 执行过程用more程序输出
-L 将压缩文件中的全部文件名改为小写
例子
1.将压缩文件文件内容用more程序打开【不产生解压的文件】
# unzip -p test.zip | more[root@MIS-BJ-6-521 test]# unzip -p test.zip | more -1 aaaaaa sdfdsf --More--
2.将压缩文件执行过程用more打开【生成解压的文件】
# unzip -M test.zip | more[root@MIS-BJ-6-521 test]# unzip -M test.zip | more -1 Archive: test.zip creating: test/ inflating: test/a --More--
3.查看压缩文件目录
# unzip -l test.zip[root@MIS-BJ-6-521 test]# unzip -l test.zip Archive: test.zip Length Date Time Name --------- ---------- ----- ---- 0 03-29-2016 14:04 test/ 19 03-29-2016 14:03 test/a 13 03-29-2016 14:03 test/c 0 03-29-2016 14:03 test/test2/ 13 03-29-2016 14:03 test/test2/b --------- ------- 45 5 files
4.查看压缩文件目录
# unzip test.zip -x test/c[root@MIS-BJ-6-521 test]# unzip test.zip -x test/c Archive: test.zip creating: test/ inflating: test/a creating: test/test2/ inflating: test/test2/b
zip命令
主要功能:压缩zip文件使用方式:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
将压缩文件file[.zip]中list列表的文件解压到exdir文件夹下,其中解排除-x list列表的压缩文件
参数说明
-f 只是更新文件-d 删除指定的文件
-r 递归处理
-f 只是更新文件
-o 以压缩文件内拥有最新更改时间的文件为准,将压缩文件的更改时间设成和该文件相同。
-q 不显示执行过程
-c 为每个被压缩的文件加上注释
-x 剔除符合条件的文件
-F 修复压缩文件
-T 检查压缩文件正确无误
-u 更新和添加新文件
-m 将文件添加到压缩文件,并删除原文件
-j 只保存文件不保存目录
-l 压缩文件时,把LF字符 置换成LF+CR字符(linux换行->win换行)
-ll 压缩文件时,把LF+CR字符 置换成LF字符(win换行->linux换行)
-z 替压缩文件加上注释
-i 只包含符合条件的文件
-n不压缩具有特定字尾字符串(文件扩展名)的文件(但是会存储到压缩文件里面)
-b 指定暂时存放文件的目录
-t 把list里面修改时间晚于指定时间点的文件,放到压缩文件里面(网上有的地方错写成压缩文件修改为此时间)
例子
1.排除test/c文件,打包test文件夹为test.zip
# zip -r test.zip test -x test/c[root@MIS-BJ-6-521 test]# zip -r test.zip test -x test/c adding: test/ (stored 0%) adding: test/a (deflated 5%) adding: test/test2/ (stored 0%) adding: test/test2/b (deflated 23%) --More--
2.修改test/a文件,更新1打包的文件夹文件,并不会添加test/c文件
# zip -rf test.zip test[root@MIS-BJ-6-521 test]# zip -rf test.zip test freshening: test/ (stored 0%) freshening: test/a (stored 0%)
3.修改test/a文件,更新并添加1打包的文件夹文件,会添加test/c文件并更新test/a
# # zip -ru test.zip test[root@MIS-BJ-6-521 test]# zip -ru test.zip test updating: test/ (stored 0%) updating: test/a (stored 0%) adding: test/c (deflated 23%)
4.不压缩扩展名为.txt 的文件,此时处理a.txt直接将文件存储到压缩文件,并未进行压缩
# # zip -r -n .txt test.zip test[root@MIS-BJ-6-521 test]# zip -r -n .txt test.zip test adding: test/ (stored 0%) adding: test/c (deflated 23%) adding: test/test2/ (stored 0%) adding: test/test2/b (deflated 23%) adding: test/a.a (stored 0%)
test1.zip 是未压缩a.txt test.zip是压缩了a.txt
-rw-r--r--. 1 root root 1136 Mar 29 16:15 test1.zip -rw-r--r--. 1 root root 796 Mar 29 16:14 test.zip
相关文章推荐
- Linux SSH命令大全
- 开发人员必知的8个常用linux命令
- 11个有用的Linux命令
- Linux系统管理常用命令及参数说明中文版
- Linux系统信息查看常用命令
- 致命的7个Linux命令
- 在PHP中运行Linux命令并启动SSH服务的例子
- Ubuntu 常用命令集
- linux下查找命令汇总(转)
- ctags --- 每天一个 Linux 命令
- Linux中文件的压缩与解压缩命令操作示例集锦
- 全面解析Linux的grep命令中正则表达式的用法
- Linux中使用grep命令搜索文件名及文件内容的方法
- Linux中文本处理命令sed的使用示例分享
- 详解Linux系统中su和sudo命令的用法
- 举例讲解Linux下grep命令的精彩使用技巧
- Linux中控制文件权限修改的chgrp和umask命令用法
- Linux中的文件压缩命令tar与rar的用法总结
- Linux下用gzip和unzip命令来压缩和解压文件的用法
- Linux系统中安装使用Bzip2来压缩文件的方法讲解