当我gunzip -dc /path_to_tar.gz_file/zip1.tar.gz | tar xf -在文件所在的目录中运行时tar.gz,它提取得很好。
我如何告诉它将tar.gz文件中的内容放入特定目录?
我试过这个gunzip -dc /path_to_tar.gz_file/zip1.tar.gz | tar xf /target_directory有tar错误。
我还应该在此注意,我试图在 bash 脚本中执行此操作,并且我正在运行 Solaris 10。
小智 14
您可以执行一个tar命令来提取您想要的内容:
tar -zxvf path_to_file -C output_directory
Run Code Online (Sandbox Code Playgroud)
如tar 联机帮助页中所述:
-C 目录、--cd 目录、--directory 目录
在 c 和 r 模式下,这会在添加以下文件之前更改目录。在 x 模式下,打开存档后但在从存档中提取条目之前更改目录。
当您补充说您正在使用Solaris 时,我想您可以尝试:
gunzip -dc path_to_file | tar xf - -C path_to_extract
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45094 次 |
| 最近记录: |