Merge pull request #2257 from geekpi/master

translated
This commit is contained in:
geekpi 2015-01-18 15:24:59 +08:00
commit a76be45006
2 changed files with 63 additions and 65 deletions

View File

@ -1,65 +0,0 @@
Translating----geekpi
How To Extract a Tar Files To a Different Directory on a Linux/Unix-like Systems
================================================================================
I want to extract tar file to specific directory called /tmp/data. How can I extract a tar archive to a different directory using tar command on a Linux or Unix-like systems?
You do not need to change the directory using cd command and extract files. Untarring a file can be done using the following syntax:
### Syntax ###
Typical Unix tar syntax:
tar -xf file.name.tar -C /path/to/directory
GNU/tar syntax:
tar xf file.tar -C /path/to/directory
tar xf file.tar --directory /path/to/directory
### Example: Extract files to another directory ###
In this example, I'm extracting $HOME/etc.backup.tar file to a directory called /tmp/data. First, you have to create the directory manually, enter:
mkdir /tmp/data
To extract a tar archive $HOME/etc.backup.tar into a /tmp/data, enter:
tar -xf $HOME/etc.backup.tar -C /tmp/data
To see a progress pass the -v option:
tar -xvf $HOME/etc.backup.tar -C /tmp/data
Sample outputs:
![Gif 01: tar Command Extract Archive To Different Directory Command](http://s0.cyberciti.org/uploads/faq/2015/01/tar-extract-archive-to-dir.gif)
Gif 01: tar Command Extract Archive To Different Directory Command
You can extract specific files too use:
tar -xvf $HOME/etc.backup.tar file1 file2 file3 dir1 -C /tmp/data
To extract a foo.tar.gz (.tgz extension file) tarball to /tmp/bar, enter:
mkdir /tmp/bar
tar -zxvf foo.tar.gz -C /tmp/bar
To extract a foo.tar.bz2 (.tbz, .tbz2 & .tb2 extension file) tarball to /tmp/bar, enter:
mkdir /tmp/bar
tar -jxvf foo.tar.bz2 -C /tmp/bar
--------------------------------------------------------------------------------
via: http://www.cyberciti.biz/faq/howto-extract-tar-file-to-specific-directory-on-unixlinux/
作者:[nixCraft][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.cyberciti.biz/tips/about-us

View File

@ -0,0 +1,63 @@
如何在Linux/类Unix系统中解压tar文件到不同的目录中
================================================================================
我想要解压一个tar文件到一个指定的目录叫/tmp/data。我该如何在Linux或者类Unix的系统中使用tar命令解压一个tar文件到不同的目录中
你不必使用cd名切换到其他的目录并解压。可以使用下面的语法解压一个文件
### 语法 ###
典型Unix tar语法
tar -xf file.name.tar -C /path/to/directory
GNU/tar 语法:
tar xf file.tar -C /path/to/directory
tar xf file.tar --directory /path/to/directory
### 示例:解压文件到另一个文件夹中 ###
在本例中。我解压$HOME/etc.backup.tar到文件夹/tmp/data中。首先你需要手动创建这个目录输入
mkdir /tmp/data
要解压$HOME/etc.backup.tar 到/tmp/data中输入
tar -xf $HOME/etc.backup.tar -C /tmp/data
要看到进度,使用-v选项
tar -xvf $HOME/etc.backup.tar -C /tmp/data
示例输出:
![Gif 01: tar Command Extract Archive To Different Directory Command](http://s0.cyberciti.org/uploads/faq/2015/01/tar-extract-archive-to-dir.gif)
Gif 01: tar命令解压文件到不同的目录
你也可以指定解压的文件:
tar -xvf $HOME/etc.backup.tar file1 file2 file3 dir1 -C /tmp/data
要解压foo.tar.gz.tgz扩展文件包到/tmp/bar中输入
mkdir /tmp/bar
tar -zxvf foo.tar.gz -C /tmp/bar
要解压foo.tar.bz2.tbz, .tbz2 和 .tb2 扩展文件)包到/tmp/bar中输入
mkdir /tmp/bar
tar -jxvf foo.tar.bz2 -C /tmp/bar
--------------------------------------------------------------------------------
via: http://www.cyberciti.biz/faq/howto-extract-tar-file-to-specific-directory-on-unixlinux/
作者:[nixCraft][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.cyberciti.biz/tips/about-us