Extract the specified file from the compressed package using the TAR command

Source: Internet
Author: User
Tags config json

The tar command not only extracts a package, but also extracts the files that are specified in the software package. Today a friend asked me, I just went to find the information, hehe

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

For example, to extract json.c This file, you can use the following

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

See, has been decompressed out.

We can also extract multiple files inside.

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, the files we need are already unpacked.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.