天天看点

tar从压缩包里解压出指定文件

tar命令不仅仅可以解压一个软件包,还可以解压软件包里的指定的文件。今天一朋友问我的,我才去找的资料,呵呵

root@ubuntu:/tmp# tar -tf json-1.2.1.tgz  

package.xml 

json-1.2.1/README 

json-1.2.1/config.m4 

json-1.2.1/config.w32 

json-1.2.1/json.dsp 

json-1.2.1/json.c 

json-1.2.1/JSON_parser.c 

json-1.2.1/JSON_parser.h 

json-1.2.1/php_json.h 

json-1.2.1/utf8_decode.c 

json-1.2.1/utf8_decode.h 

json-1.2.1/utf8_to_utf16.c 

json-1.2.1/utf8_to_utf16.h 

json-1.2.1/tests/fail001.phpt 

json-1.2.1/tests/pass001.phpt 

json-1.2.1/tests/pass001.1.phpt 

json-1.2.1/tests/pass002.phpt 

json-1.2.1/tests/pass003.phpt 

比如要解压json.c这个文件,可以使用以下

root@ubuntu:/tmp# tar xf json-1.2.1.tgz json-1.2.1/json.c  

tar: A lone zero block at 228 

root@ubuntu:/tmp# ls 

json-1.2.1  json-1.2.1.tgz 

root@ubuntu:/tmp# ls json-1.2.1/ 

json.c 

看到,已经被解压出来了。

我们也可以解压里面的多个文件

root@ubuntu:/tmp# tar xf json-1.2.1.tgz  json-1.2.1/tests/pass003.phpt  json-1.2.1/tests/pass002.phpt 

root@ubuntu:/tmp# ls json-1.2.1/tests/ 

pass002.phpt  pass003.phpt 

OK,我们需要的文件已经解压出来了。

本文转自 gm100861 51CTO博客,原文链接:http://blog.51cto.com/gm100861/899517

下一篇: PLSQL

继续阅读