- 环境
- 虚拟机:VMware-10.0.7 build-2844087
- Linux系统:CentOS 6.8
- 远程工具:Xshell 6 (Build 0197)
一、问题重现
今天在编写批量解压缩脚本时,使用tar解压所有压缩包的时候遇到此类问题,经网络一番查找找出问题所在,原来是解压缩文件时没有考虑文件类型导致。
以下是问题提示:
tar -zxvf xxxxx.tgz
tar: 它似乎不像是一个 tar 归档文件
tar: 跳转到下一个头
tar: 由于前次错误,将以上次的错误状态退出
二、问题解决
2.1、使用file命令查看压缩类型
2.1、使用gzip解压文件
[root@localhost tar]# gzip -d ntfs-3g_ntfsprogs-2021.8.22.tgz
[root@localhost tar]# ll
总用量 656528
drwxr-xr-x. 2 root root 4096 7月 30 16:59 .
drwxr-xr-x. 3 root root 4096 7月 30 05:11 ..
-rw-r--r--. 1 root root 666603757 7月 17 20:40 mysql-5.7.