目录
2.在Linux上的/root目录创建一个Linux.txt,在windows上创建windows.txt
1.使用tar命令对文件进行打包压缩与解压缩
tar参数
-A 新增压缩文件到已存在的压缩
-B 设置区块大小
-c 建立新的压缩文件
-d 记录文件的差别
-r 添加文件到已经压缩的文件
-u 添加改变了和现有的文件到已经存在的压缩文件
-x 从压缩的文件中提取文件
-t 显示压缩文件的内容
-z 支持gzip解压文件
-j 支持bzip2解压文件
-Z 支持compress解压文件
-v 显示操作过程
-l 文件系统边界设置
-k 保留原有文件不覆盖
-m 保留文件不被覆盖
-W 确认压缩文件的正确性
可选参数如下:
-b 设置区块数目
-C 切换到指定目录
-f 指定压缩文件
--help 显示帮助信息
--version 显示版本信息
使用gzip方式对文件进行压缩,并指定压缩名为 tar_gzip.tar.gz
-z, --gzip, --gunzip, --ungzip filter the archive through gzip
[root@localhost ~]# tar -czf tar_gzip.tar.gz bfile bbfile
-rw-r--r-- 1 root root 124 Jul 17 17:17 tar_gzip.tar.gz
使用bzip2方式对文件夹进行压缩,并指定压缩名为 tar_bzip2.tar.bz2
-j, --bzip2 filter the archive through bzip2
root@localhost ~]# tar -cjf tar_bzip2.tar.bz2 bfile bbfile
-rw-r--r-- 1 root root 132 Jul 17 17:25 tar_bzip2.tar.bz2
使用xz方式对文件进行压缩,并指定压缩名为 tar_xz.tar.xz
-J, --xz filter the archive through xz
[root@localhost ~]# tar -cJf tar_xz.tar.xz new_file
-rw-r--r-- 1 root root 208 Jul 17 17:30 tar_xz.tar.xz
新建文件file1.txt,file2.txt,file3.txt
对文件file1.txt和file2.txt,进行压缩(使用gzip方式),排除file3.txt(即不对file3进行压缩)
并指定压缩名为tar