How to Extract (Unzip) Tar Bz2 File
The tar order permits you to make and concentrate tar documents. It bolsters a tremendous scope of pressure projects, for example, gzip, bzip2, lzip, lzma, lzop, xz and pack.
Bzip2 is one of the most famous calculations for packing tar documents. By show, the name of a tar file packed with bzip2 closes with either .tar.bz2 or .tbz2.
In this instructional exercise, we will disclose how to extricate (or unfasten) tar.bz2 and tbz2 chronicles utilizing the tar order.
Extracting tar.bz2 File
Most Linux appropriations and macOS accompanies the tar utility pre-introduced of course.
To separate a tar.bz2 record, utilize the - remove (- x) choice and indicate the chronicle document name after the - f alternative:
tar -xf archive.tar.bz2
The tar order auto-recognizes pressure type and concentrates the document. A similar order can be utilized to separate tar files packed with different calculations, for example, .tar.gz or .tar.xz .
In the event that you are a Desktop client and the order line isn't your thing you can utilize your File supervisor. To extricate (unfasten) a tar.bz2 document just right-click the record you need to separate and choose "Concentrate". Windows clients will require an instrument named 7zip to remove tar.bz2 documents.
For more verbose yield utilize the - v choice. This alternative advises tar to show the names of the records being extricated on the terminal.
tar -xvf archive.tar.bz2
Of course, tar will separate the document substance in the current working catalog . Utilize the - index (- C) to extricate document records in a particular catalog:
For instance, to separate the document substance to the/home/linuxize/records catalog, you would type:
tar -xf archive.tar.bz2 -C /home/linuxize/files
Extracting Specific Files from a tar.bz2 File
To remove a particular file(s) from a tar.bz2 record, affix a space-isolated rundown of document names to be separated after the file name:
tar -xf archive.tar.bz2 file1 file2
When removing records, you should give their precise names including the way, as printed when the - list (- t) alternative is utilized.
Removing at least one indexes from a document is equivalent to separating numerous records:
tar -xf archive.tar.bz2 dir1 dir2
In the event that you attempt to extricate a record that doesn't exist in the document, a mistake message like the accompanying will be appeared:
tar -xf archive.tar.bz2 README
tar: README: Not found in archive
tar: Exiting with failure status due to previous errors
The - trump cards choice permits you to extricate documents from a tar.bz2 record dependent on a special case design. The example must be cited to keep the shell from deciphering it.
For instance, to extricate just the records whose names end in .md (Markdown documents), you would utilize:
tar -xf archive.tar.bz2 --wildcards '*.md'
Extracting tar.bz2 File from stdin
While removing a packed tar.bz2 record by perusing the file from standard info (ordinarily through channeling), you should indicate the decompression choice. The - j choice tells tar that the record is packed with bzip2.
In the model underneath we are downloading the Vim sources utilizing the wget order and line its yield to the tar order:
wget -c ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2 -O - | sudo tar -xj
On the off chance that you don't determine a decompression choice, tar will show you which choice you should utilize:
tar: Archive is compressed. Use -j option
tar: Error is not recoverable: exiting now
Listing tar.bz2 File
To list the substance of a tar.bz2 record, utilize the - list (- t) choice:
tar -tf archive.tar.bz2
The yield will look something like this:
file1
file2
file3
In the event that you add the - verbose (- v) choice, tar will print more data, for example, proprietor, record size, timestamp ..and so on:
tar -tvf archive.tar.bz2
-rw-r--r-- linuxize/users 0 2019-02-15 01:19 file1
-rw-r--r-- linuxize/users 0 2019-02-15 01:19 file2
-rw-r--r-- linuxize/users 0 2019-02-15 01:19 file3
Conclusion
tar.bz2 document is a Tar file packed with Bzip2. To remove a tar.bz2 document, utilize the tar - xf order followed by the chronicle name.
In the event that you have any inquiries, it would be ideal if you leave a remark beneath.