Linux压缩及解压缩
发布时间:2022-10-10 13:03:38 所属栏目:Linux 来源:
导读: 压缩文件
生成一个大小800M的test.txt文件
[root@localhost ~]# dd if=/dev/zero of=test.txt bs=100M count=8
记录了8+0 的读入
记录了8+0 的写出
838860800字节(839 MB)已复制
生成一个大小800M的test.txt文件
[root@localhost ~]# dd if=/dev/zero of=test.txt bs=100M count=8
记录了8+0 的读入
记录了8+0 的写出
838860800字节(839 MB)已复制
压缩文件 生成一个大小800M的test.txt文件 [root@localhost ~]# dd if=/dev/zero of=test.txt bs=100M count=8 记录了8+0 的读入 记录了8+0 的写出 838860800字节(839 MB)已复制,34.2868 秒,24.5 MB/秒 [root@localhost ~]# zip文件压缩 zip test.zip test.txt zip 压缩后的文件名 要压缩的文件 [root@localhost ~]# ls anaconda-ks.cfg initial-setup-ks.cfg test.txt [root@localhost ~]# zip wah.zip test.txt adding: test.txt (deflated 100%) [root@localhost ~]# ls anaconda-ks.cfg initial-setup-ks.cfg test.txt wah.zip [root@localhost ~]# zip文件解压缩 unzip test.zip [root@localhost ~]# unzip wah.zip Archive: wah.zip replace test.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y inflating: test.txt [root@localhost ~]# unzip 要解压的文件名 -d 指定解压路径 [root@localhost ~]# ls /home wah [root@localhost ~]# unzip wah.zip -d /home Archive: wah.zip inflating: /home/test.txt [root@localhost ~]# ls /home test.txt wah [root@localhost ~]# tar压缩与解压缩 -c 建立一个压缩文件 -x 解开一个压缩文件 -t 查看tar压缩文件里面的文件 以上三个参数不能同时使用,只能存在一个 -z 使用gzip压缩 -j 使用bzip2压缩 -v 压缩过程中显示文件*(常用)但不建议用在背景执行过程! -f使用档名,注意:f之后要立即接档名,不能再接参数 eg:tar -zcvfP tfile sfile 这样写是不正确的 eg:tar -zcvPf tfile sfile 这样是正确的 以上是tar常用的参数 -P 可以使用绝对路径进行压缩 -p 使用原文件的原属性(属性不会根据使用者而改变) -N 后面接的是日期,比(yyyy/mm/dd)次日期之后还要新的文件才会被打包 eg:tar -zcvf test.tar /etc eg:tar -cvf test.tar /etc 仅打包linux压缩,不压缩 eg:tar -xvf test.tar tar [参数] 文件与目录... ... 注意:打包只是把文件进行归档,打包文件体积大小不变 打包可以理解为把衣服放进压缩袋里面,压缩则是将里面的空气抽空 (编辑:拼字网 - 核心网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐