linux命令tar解压到指定目录下
linux命令tar解压到指定目录下详细介绍
在 Linux 系统中,你可以使用tar命令将压缩文件解压到指定目录。下面为你介绍几种常见压缩格式的解压方法。
解压
.tar文件
若要将example.tar文件解压到/path/to/destination目录,可使用如下命令:
bash
example.tar /path/to/destination
在这个命令里:
-x表示要执行解压操作。-v会详细列出解压过程中的文件。-f用于指定要解压的文件。-C则用来指定解压的目标目录。
解压
.tar.gz或
.tgz文件
若要将example.tar.gz或者example.tgz文件解压到/path/to/destination目录,可使用如下命令:
bash
example.tar.gz /path/to/destination
这里的-z表示使用 gzip 压缩算法进行解压。
解压
.tar.bz2文件
若要将example.tar.bz2文件解压到/path/to/destination目录,可使用如下命令:
bash
example.tar.bz2 /path/to/destination
其中的-j表示使用 bzip2 压缩算法进行解压。
解压
.tar.xz文件
若要将example.tar.xz文件解压到/path/to/destination目录,可使用如下命令:
bash
example.tar.xz /path/to/destination
912tar example.tar.xz /path/to/destination
这里的-J表示使用 xz 压缩算法进行解压。
请把example.tar、example.tar.gz、example.tar.bz2、example.tar.xz替换成你实际要解压的文件名,把/path/to/destination替换成你期望的解压目标目录。