Linux命令 ar -建立或修改備存文件,或是從備存文件中抽取文件

2021-10-08 12:03 更新

ar命令

建立或修改備存文件,或是從備存文件中抽取文件

補(bǔ)充說(shuō)明

ar命令 是一個(gè)建立或修改備存文件,或是從備存文件中抽取文件的工具,ar可讓您集合許多文件,成為單一的備存文件。在備存文件中,所有成員文件皆保有原來(lái)的屬性與權(quán)限

語(yǔ)法

ab(選項(xiàng))(參數(shù))
Usage: ar [emulation options] [-]{dmpqrstx}[abcDfilMNoPsSTuvV] [--plugin <name>] [member-name] [count] archive-file file...
       ar -M [<mri-腳本]

選項(xiàng)

d            - 從歸檔文件中刪除文件
m[ab]        - 在歸檔文件中移動(dòng)文件
p            - 打印在歸檔文件中找到的文件
q[f]         - 將文件快速追加到歸檔文件中
r[ab][f][u]  - 替換歸檔文件中已有的文件或加入新文件
s            - act as ranlib
t            - 顯示歸檔文件的內(nèi)容
x[o]         - 從歸檔文件中分解文件
特定命令修飾符:
[a]          - 將文件置于 [成員名] 之后
[b]          - 將文件置于 [成員名] 之前 (于 [i] 相同)
[D]          - use zero for timestamps and uids/gids
[U]          - use actual timestamps and uids/gids (default)
[N]          - use instance [count] of name
[f]          - truncate inserted file names
[P]          - 在匹配時(shí)使用完整的路徑名
[o]          - 保留原來(lái)的日期
[u]          - 只替換比當(dāng)前歸檔內(nèi)容更新的文件
通用修飾符:
[c]          - 不在必須創(chuàng)建庫(kù)的時(shí)候給出警告
[s]          - 創(chuàng)建歸檔索引 (cf. ranlib)
[S]          - 不要?jiǎng)?chuàng)建符號(hào)表
[T]          - 做一個(gè)壓縮檔案
[v]          - 輸出較多信息
[V]          - 顯示版本號(hào)
@<file>      - 從<file>讀取選項(xiàng)
--target=BFDNAME - 將目標(biāo)對(duì)象格式指定為BFDNAME

選項(xiàng)參數(shù)

--plugin <p> - load the specified plugin

ar:支持的目標(biāo): ?elf64-x86-64?  ?elf32-i386 ? ?elf32-x86-64? ?a.out-i386-linux? ?pei-i386?  ?pei-x86-64? ?elf64-l1om? ?elf64-k1om? ?elf64-little? ?elf64-big? ?elf32-little? ?elf32-big? ?plugin? ?srec? ?symbolsrec ??verilog ??tekhex ??binary ??ihex?

實(shí)例

打包文件

[root@localhost ~]# ls   //顯示當(dāng)前目錄文件   
a.c    b.c d.c   install.log      qte
anaconda-ks.cfg c.c Desktop 

[root@localhost ~]# ar rv one.bak a.c b.c //打包 a.c b.c文件 
ar: 正在創(chuàng)建 one.bak
a - a.c
a - b.c

打包多個(gè)文件

[root@localhost ~]# ar rv two.bak *.c  //打包以.c結(jié)尾的文件  
ar: 正在創(chuàng)建 two.bak
a - a.c
a - b.c
a - c.c
a - d.c

顯示打包文件的內(nèi)容

[root@localhost ~]# ar t two.bak    
a.c
b.c
c.c
d.c

刪除打包文件的成員文件

[root@localhost ~]# ar d two.bak a.c b.c c.c  
[root@localhost ~]# ar t two.bak       
d.c


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)