您的位置:首页 > 其它

tar命令简介-常用功能

2016-03-24 22:08 309 查看
tar命令是linux中非常实用的一个命令,是非常基础以及常用的。

本文只做非常简单和常用命令的介绍。如果需要了解完整用法,可以在linux终端中输入
man tar
或者
tar --useage
或者
tar --help


tar命令一定要指定参数才能正确执行。

tar命令的语法

tar [options][files]


例如:

tar zxvf test.tar.gz
, 将压缩包test.tar.gz解压

tar cvf a.tar 1.txt 2.txt
, 将1.txt和2.txt压缩到a.tar中

tar xvf a.tar
,解压缩a.tar

tar tf a.tar
, 列出a.tar中的文件

The options used most often with tar are as follows:

c Creates a new backup,overwriting any files already on the backup destination.

x Extracts files from backup media.

t Lists the contents of backup media.

v Displays the name of each file being processed.

f Creates backups on a specified device.

u Adds files to the backup if they are not already there,or if they have been modified since they were last written on the backup.

常用的参数

c 创建一个压缩包

x 解压一个压缩包

v 执行命令过程中显示冗余(详细)信息

f 指定要被执行的文件

z 调用gzip联合来对文件进行压缩、解压

r 追加文件到压缩包中

最常用的参数组合

zcvf 联合gzip压缩文件并显示详细信息,压缩包名称应该为*.tar.gz

zxvf 联合gzip解压文件并显示详细信息,被解压的文件名称应为*.tar.gz

cvf 压缩文件并显示详细信息,压缩包名称应该为*.tar

zvf 解压文件并显示详细信息,被解压的文件名称应为*.tar

tvf 显示压缩包中的文件详细列表

vf 显示压缩包中的文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: