Linux命令-tar

  • tar命令用于对文件打包压缩或解压
  • 格式:tar [选项 -C 指定解压到的目录] [文件]
  • 打包并压缩文件:
tar -zcvf 压缩包名.tar.gz 文件名
  • 解压并展开压缩包
tar -zxvf 压缩包名.tar.gz

 

[root@localhost testB]# ls
111.txt  222.txt

将111.txt文件通过gzip打包保存文件名111.tar.gz [root@localhost testB]# tar zcvf
111.tar.gz 111.txt 111.txt [root@localhost testB]# ls 111.tar.gz 111.txt 222.txt [root@localhost testB]# rm -rf 111.txt [root@localhost testB]# ls 111.tar.gz 222.txt
解压111.tar.gz到当前目录
[root@localhost testB]# tar zxvf
111.tar.gz 111.txt [root@localhost testB]# ls 111.tar.gz 111.txt 222.txt
解压111.tar.gz到指定目录/root/testC下 [root@localhost testB]# tar
-zxvf 111.tar.gz -C /root/testC/ 111.txt [root@localhost testB]# ll /root/testC/ 总用量 4 -rw-r--r--. 1 root root 3 9月 7 15:23 111.txt

 

posted @ 2016-09-07 15:42  北海悟空  阅读(171)  评论(0编辑  收藏  举报