You are reading the article How Untar Command Works In Linux With Examples? updated in September 2023 on the website Lanphuongmhbrtower.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested October 2023 How Untar Command Works In Linux With Examples?
Definition of Linux UntarUntar is a command that enables users to extract compressed files with tar, chúng tôi and chúng tôi compression formats. This command is used for 2 specific utilities in file operations. It first helps the user to extract or, in other words, unpack files in the compressed mode, and once the unpacking or extraction is done, the command helps the user to uncompress the same. Listing content and extracting a single file or directory are some of the widely used utilities of the command untar. In this article, we will go through all the command utilities and take deep dive using some examples to understand them in even greater detail!
Syntax:
In Linux, there are fewer options available for untar compared to other extensively used commands, and we will discuss all of those in detail here in this section later in the article, take a dig at the working of untar commands in Linux.
1. Extraction of the tar file
Syntax:
2. Extraction of the chúng tôi file
Syntax:
3. Extraction of chúng tôi file
Syntax:
4. Untar tar archive File at the desired location
Syntax:
5. List Content of tar Archive File
Syntax:
6. List Content of chúng tôi Archive File
Syntax:
7. List the Content of chúng tôi Archive File
Syntax:
8. Extract a single file from the tar Archive File
Syntax:
9. Extract all files from the tar Archive File matching a particular file regex
Syntax:
How does Untar Command work in Linux?In the computation world, there are two different versions of tar, namely BSD tar and GNU tar. By default, most Linux is pre-installed with GNU tar. Another similar process of untar is gzip utility with the command gunzip. Now, talking about the different options of utility of untar, they are the following 4 options:
x – provides an option to the tar command to extract files from the given tar file.
v – commands the tar to list out the files as they get extracted.
z – commands the tar command to decompress, without which, by default, the tar command will compress instead of decompressing.
f – helps specify the filename that needs to be worked on for the untar process.
In the above few options, we look at all the widely used utilities. Apart from this, we also have other utilities like:
C option: This option helps untangle the specified files to a particular path location; in case one needs this utility.
Delete option: Though not a part of untar option, a utility closely associated with untar is the removal of a file from a tar archive. Using the –delete option assists the user in deleting a specific file in a tar archive.
ExamplesLet us discuss examples of Linux Untar.
Example #1Extraction of tar file
Syntax:
tar -xvf eduCBA-demo.tarOutput
Here we see that at first, there are no such files present while we have the directory, but as we untar the file, all the file contents get extracted and uncompressed to the location where we are running the command from. A similar explanation goes for the below 2 examples (for chúng tôi and tar.bz2).
Example #2Extraction of the chúng tôi file
Syntax:
tar - xvzf eduCBA-demo.tar.gzOutput:
Example #3Extraction of chúng tôi file
Syntax:
tar -xvjf eduCBA-demo.tar.bz2Output:
Example #4Untar tar archive File at the desired location
Syntax:
tar -xvf chúng tôi -C desiredLocOutput:
Here we see that the location desiredLoc has no files under it, and as we extract the file, all the file contents get extracted to the location specified i.e. desiredLoc.
Example #5List Content of tar Archive File
Syntax:
tar -tvf eduCBA-demo.tarOutput:
Example #6List Content of chúng tôi Archive File
Syntax:
tar -ztvf eduCBA-demo.tar.gzOutput:
Example #7List the Content of chúng tôi Archive File
Syntax:
tar -jtvf eduCBA-demo.tar.bz2Output:
Example #8Extract single file from tar Archive File
Syntax:
tar -xvf chúng tôi file1.txtOutput:
Example #9Extract all files from tar Archive File matching a particular file regex
Syntax:
tar -xvf chúng tôi --wildcards '*.txt'Output:
In this example, we see that only the files with “txt” as an extension get untarred in the location!
Conclusion Recommended ArticlesWe hope that this EDUCBA information on “Linux Untar” was beneficial to you. You can view EDUCBA’s recommended articles for more information.
You're reading How Untar Command Works In Linux With Examples?
Update the detailed information about How Untar Command Works In Linux With Examples? on the Lanphuongmhbrtower.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!