加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_宿迁站长网 (https://www.0527zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

使用tar命令从压缩包里解压出指定文件

发布时间:2016-09-10 01:51:13 所属栏目:Linux 来源:站长网
导读:tar命令不仅仅可以解压一个软件包,还可以解压软件包里的指定的文件。今天一朋友问我的,我才去找的资料,呵呵 root@ubuntu:/tmp# tar -tf json-1.2.1.tgz pack

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这个文件,可以使用以下

URL:http://www.bianceng.cn/OS/Linux/201410/46057.htm

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 
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/tests/ 
pass002.phpt  pass003.phpt

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

(编辑:云计算网_宿迁站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!