![linux untar command linux untar command](https://techgoeasy.com/wp-content/uploads/2016/11/tar-add-new-file-archive.png)
One thing to be careful about here is to see if files are in the archive with an absolute path. However, if the file was in a sub-directory named bar, you'd want to specify your un-tar command like this: For instance, if your file is named "foo" and it's in the root directory of the archive, you'd use this command: The secret here is that you need to specify your filename just as it is in the tar archive. Now, to answer the question, if you want to un-tar one file named "my-desired-file" from a tar archive named "my-archive.tgz", and assuming the archive is compressed as most are these days, you'd use a command like this:
![linux untar command linux untar command](http://vcloud-lab.com/files/images/fbe7873c-d080-4381-9535-60499a956ef3.png)
Linux untar command how to#
For example, if you wanted to extract all the text files, you would use *.txt.Tar extract FAQ: How do I extract one file (or multiple files) from a tar archive without extracting the entire archive (i.e., how do I un-tar files from a tar archive)? Extract all files from a tar archiveįirst, if you really want to extract a tar archive completely (un-tar a tar archive), I've written about that before in my How to extract a tar archive tutorial and my Linux tar command examples, so I won't repeat those tutorials much, other than to say that this command is common to un-tar an uncompressed tar archive:Īnd this command is common to un-tar a compressed tar archive:Įxtract (un-tar) one file from a tar archive Here, you can use your specific extension. In this case, you could use a wildcard like *.extension format. Let’s say you want to extract all the files that have the same extension from inside of an archive. Use wildcards for specific file extensions Here, dir1, dir2, and dir3 are the names of the directories/folders you want to extract from the archive. The command would look like the following: tar -xf dir1 dir2 dir3… You can also extract specific directories/folders by using this method.
![linux untar command linux untar command](https://www.testingdocs.com/questions/wp-content/uploads/java-version-linux-1536x864.png)
Now let’s check our working directory again with the ls command: compressed_ file file.log Īs you can see, the file and file.log have been extracted from the compressed_ archive. We also mentioned file and file.log indicating which files to extract. Here, we used the -xf flag with the command to extract the compressed_ archive. We’ll be using the following command: tar -xf compressed_ file file.log Now let’s extract file and file.log from this archive. I have already shown you the content of the compressed_ in the previous section (listing files). If you just wanted to take a look at the contents of an archive, you would use the -t or -list flag: tar -tf compressed_ Let’s take a look at some other options now. You’ve already seen the usage of the -x flag for extracting an archive. x, -extract, -get extract files from an archive t, -list list the contents of an archive Below are three of these options: -c, -create create a new archive This mode has some basic options for creating and extracting archives. We’ll be using the main operation mode most of the time. You can access it by typing in tar -help. The tar command has a plethora of options in the help menu. The basic syntax of the tar command is as follows: tar Just right click on the tar gz archive file you want to extract and click on the Extract option. For example, you could extract a tar.gz file with the same command.Īlternatively, you can also use the graphical user interface (GUI) instead of the command line. You don’t need to specify the file/compression type to extract. The tar command detects the compression type automatically and extracts it. Here, x stands for extract and f stands for the archive file. To extract all the files inside of a tar.gz file, use the -xf flag with the tar command: tar -xf In the later sections, you will get to know the tar command in a little bit more detail.
![linux untar command linux untar command](https://helpdeskgeek.com/wp-content/pictures/2020/01/Tar-Linux.png)
In this section, we’ll show you a simple method to extract any tar.gz file. Extract specific files/folders from a tar gz archive.Listing the contents of a tar gz archive.