Giải nén file tar.gz

I received a huge .tar.gz file from a client that contains about 800 mb of image files (when uncompressed.) Our hosting company"s ftp is seriously slow, so extracting all the files locally and sending them up via ftp isn"t practical. I was able to ftp the .tar.gz tệp tin to lớn our hosting site, but when I ssh into lớn my directory và try using unzip, it gives me this error:

clients locations>$ unzip community_images.tar.gzArchive: community_images.tar.gz End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory & ziptệp tin comment will be found on the last disk(s) of this archive.note: community_images.tar.gz may be a plain executable, not an archiveunzip: cannot find zipfile directory in one of community_images.tar.gz or community_images.tar.gz.zip, and cannot find community_images.tar.gz.ZIP, period.What comm& vì I need to use khổng lồ extract all the files in a .tar.gz file?


*

*

Type man tar for more information, but this comm& should vày the trick:

tar -xvzf community_images.tar.gzTo explain a little further, tar collected all the files into lớn one package, community_images.tar. The gzip program applied compression, hence the gz extension. So the command does a couple things:

f: this must be the last flag of the comm&, và the tar file must be immediately after. It tells tar the name & path of the compressed file.z: tells tar lớn decompress the archive using gzipx: tar can collect files or extract them. x does the latter.v: makes tar talk a lot. Verbose output shows you all the files being extracted.

Bạn đang xem: Giải nén file tar.gz

To extract inkhổng lồ a custom folder, add the -C option with a folder name of your choice:

tar -xvzf community_images.tar.gz -C some_custom_folder_name

*

If you want the files to lớn be extracted lớn a particular destination you can add -C /destination/path/Make sure you make the directory first, in this case: ~/Pictures/Community

Example:

mkdir ~/Pictures/Communitytar xf community_images.tar.gz -C /home/emmys/Pictures/Community/You can easily memorize it if you consider telling tar to lớn e X tract a F ile

*

Note: Rethành viên you can search inside man pages with ?+term khổng lồ look for, và then n and N khổng lồ go lớn the next or previous instance of the term you are looking for.


*

At some point tar was upgraded khổng lồ auto-decompress. All you need now is:

tar xf community_images.tar.gzThe same explanation applies:

f: this must be the last flag of the comm&, và the tar file must be immediately after. It tells tar the name và path of the compressed tệp tin.x: extract the files.

lưu ý the lachồng of hyphen for the comm& flags. This is because most versions of tar allow both gnu và bsd style options (simplistically, gnu requires a hyphen, bsd doesn"t).

Xem thêm: Chọn Lọc Những Câu Nói Về Sự Thất Vọng Trong Cuộc Sống, Đầy Xót Xa


*

Remembering all flags for tar can be tedious. Obligatory XKCD:

*

Therefore I made my own little script in Pynhỏ to vì that. Quiông chồng, dirty, cp-lượt thích in usage:

#!/usr/bin/env python3import tartệp tin,sys,ostf = tartệp tin.open(name=sys.argv<1>,mode="r:gz")where = "."if len(sys.argv) == 3: where = sys.argv<2>tf.extractall(path=where)tf.close()Use it as so:

myuntar.py archive.tarSee also similar script for unzipping zip archives.


Quiông xã Answer:tar -xvf or tar -xzvf tar -xjvf <NOTE>:

-v Verbosely menu files processed.-z Filter the archive through gzip.-f Use archive sầu tệp tin or device ARCHIVE.-x Extract files from an archive.-j bzip2.tar -xf archive sầu.tar # Extract all files from archive sầu.tar.
In case you are not able to extract .tar.gz file using

tar -xvzf fileName.tar.gzTry extracting using

tar xf fileName.tar.gz
You could do this too in first step:

gunzip community_images.tar.gz

Then you have sầu the file: community_images.tar

Second step would be:

tar -xvf community_images.tar

And the *.tar tệp tin would be extracted.


tar xvf file.tar.gz

x for extractv for verbose (menu files)f for filename is next

Any remotely modern version of tar should auto-detect that the archive is gzipped, và add "z" for you.


Highly active sầu question. Earn 10 reputation (not counting the association bonus) in order to lớn answer this question. The reputation requirement helps protect this question from spam and non-answer activity.

Not the answer you're looking for? Browse other questions tagged tar compression extract gzip unzip or ask your own question.


Problem extracting tar.gz files: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options
site kiến thiết / logo © 2021 Staông xã Exchange Inc; user contributions licensed under cc by-sa. rev2021.10.27.40576


Your privacy

By clicking “Accept all cookies”, you agree Staông xã Exchange can store cookies on your device and discthua information in accordance with our Cookie Policy.