You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将多个tar文件合并为单个文件,使用--concatenate仅识别首个文件怎么办

tar --concatenate 操作多参数适配测试

根据GNU官方文档,若要将一个或多个归档文件追加到另一归档文件末尾,可使用--concatenate(对应短选项-A)操作。

但实际测试过程中发现无法一次性添加多个归档文件,测试场景如下:
当前目录下存在3个独立tar归档,目录列表如下:

# ls -al
total 724
drwxr-xr-x.  3 root root     60 Oct 14 17:40 .
dr-xr-xr-x. 32 root root   4096 Oct 14 16:28 ..
-rw-r--r--.  1 root root 245760 Oct 14 18:07 1.tar
-rw-r--r--.  1 root root 245760 Oct 14 18:07 2.tar
-rw-r--r--.  1 root root 245760 Oct 14 18:07 3.tar

各归档内部存储的文件如下:

# tar tvf 1.tar
-rw-r--r-- root/root    238525 2021-10-14 17:28 1.txt
# tar tvf 2.tar
-rw-r--r-- root/root    238525 2021-10-14 17:29 2.txt
# tar tvf 3.tar
-rw-r--r-- root/root    238525 2021-10-14 17:29 3.txt

执行多归档追加命令后,结果显示命令仅识别了第一个待追加归档参数,其余参数被忽略:

# tar -A -f 1.tar 2.tar 3.tar
# tar tvf 1.tar
-rw-r--r-- root/root    238525 2021-10-14 17:28 1.txt
-rw-r--r-- root/root    238525 2021-10-14 17:29 2.txt

该问题可通过逐次执行单归档追加操作临时规避,即分多次将待合并的归档逐个追加到目标归档中。

内容的提问来源于stack exchange,提问作者Gregory Lam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.30 11:06:04