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