Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux ar Command

Linux ar Command

Linux Command Reference Linux Command Reference

The Linux ar command is used to create or modify archives, or to extract files from archives.

ar lets you collect many files into a single archive. Within the archive, all member files retain their original attributes and permissions.

Syntax

ar[-dmpqrtx][cfosSuvV][a<成员文件>][b<成员文件>][i<成员文件>][备存文件][成员文件]

Parameters:

Required Parameters:

Optional Parameters:

Example

Create an archive



[root@runoob.com ~]# ls   //显示当前目录文件   

a.c    b.c d.c   install.log      qte

anaconda-ks.cfg c.c Desktop 



[root@runoob.com ~]# ar rv one.bak a.c b.c //打包 a.c b.c文件 

ar: 正在创建 one.bak

a - a.c

a - b.c

[root@runoob.com ~]# 

Archive multiple files



[root@runoob.com ~]# ar rv two.bak *.c  //打包以.c结尾的文件  

ar: 正在创建 two.bak

a - a.c

a - b.c

a - c.c

a - d.c

[root@runoob.com ~]# 

Display the contents of an archive



[root@runoob.com ~]# ar t two.bak    

a.c

b.c

c.c

d.c

[root@runoob.com ~]# 

Delete a member file from an archive



[root@runoob.com ~]# ar d two.bak a.c b.c c.c  

[root@runoob.com ~]# ar t two.bak       

d.c

Linux Command Reference Linux Command Reference