Sometimes it is needed just to check the contents of a tarball without unpacking it.įor example, it goes without saying, that it is inadvisable to untar the whole large archive if you need for example to extract only a dingle file or a directory from it.Īnd of course this is possible with the Linux tar command, but firstly you need to check what is there inside the tarball without unpacking it.
List the Contents of a tar, tar.gz, tar.bz2 Files
Untar .tar file download#
File extensionĬool Tip: No more wasted time! Download from the web and untar in one step from the Linux command line! Read more → Untar tar, tar.gz, tar.bx2 FilesĮxtract and uncompress a tar.gz file: $ tar -xvzf Įxtract and uncompress a tar.bz2 file: $ tar -xvjf 2 Optionĭecompress the contents of the compressed archive created by gzip program ( tar.gz)ĭecompress the contents of the compressed archive created by bzip2 program ( tar.bz2)
Untar .tar file how to#
You will learn how to list the contents of a tar archive without unpacking it and how to extract only a single file or a single directory. The following article will help you to extract (unpack) and uncompress (untar) – tar, tar.gz and tar.bz2 files from the Linux command line. tar -xvzf ukulele_ of the Linux files that can be downloaded from the Internet are compressed with a tar, tar.gz and tar.bz2 compression formats and it is important to know how to extract such files. The files and directories that would have been extracted to that directory are extracted in the target directory. If we specify -strip-components=1 with our example tar file, the Ukulele Songs top-most directory within the tar file is not created on the hard drive. Files from the ignored directories are still extracted, but the directory structure is not replicated on your hard drive.
The number represents how many levels of directories to ignore. The -strip-components option requires a numerical parameter. If you don’t want the directory structure in the tar file to be recreated on your hard drive, use the -strip-components option. tar -xvz -wildcards -f ukulele_ "Ukulele Songs/Possibles/B*"Įxtracting Files Without Extracting Directories Using wildcards requires the use of the -wildcards option. You can extract a selection of files by using wildcards, where * represents any string of characters and ? represents any single character. tar -xvzf ukulele_ "Ukulele Songs/023 - My Babe.odt" To extract a single file, provide the path and the name of the file. If we want to extract the files to a location other than the current directory, we can specify a target directory using the -C (specified directory) option. If we list the files in the Download directory we will see that another directory called Guitar Songs has been created.