Several compressed files are included in a TAR.GZ file to reduce download bandwidth and storage space.
Sometimes referred to as a tarball, the
.TAR file serves as a portable container for other files.
.GZ suffix refers to GZIP, a widely used compression tool.
GZIP extracts the file into the current directory by default.
To verify that the file has been compressed after zipping it, type the command
The GUNZIP command can be used to decompress a file:
Enter the following to compress every
.txt file in a specific directory:
tar -czvf directory.tar.gz *.txt
A TAR file combined with a GZ file is called a TAR.GZ file.
These files can be unzipped in the same manner as a standard zipped file:
tar -xzvf file.tar.gz
TAR is the standard command, and it has four options:
-ccreates a new archive
-xextracts files from an archive
-zfilters the archive through gzip
-vdisplays verbose output
Enter the following to view a
.TAR file’s contents before you extract it:
tar -tvf file.tar
To give TAR instructions about where to store the extracted, unzipped files, enter:
tar -xvf file.tar -C /path/to/directory
The command to create a TAR.GZ file is as follows:
tar -czvf archive.tar.gz file1 file2 file3
Use the following command to append several files to a tar file:
tar -rvf archive.tar file1 file2 file3
In order to retrieve the files from a tar file, type:
tar -xvf archive.tar
Additionally, you can use
tar to create a
tar.gz archive and add files from the
find command to it.
A command-line tool for managing
tar.gz files is included in some graphical user interfaces.
Let’s explore Linux command line file extraction.
unzip command and the ZIP file name to extract the files from a ZIP file. It should be noted that the
.zip extension is required.
The files are listed in the terminal window as they are extracted.
ZIP files don’t store file ownership information. The owner of every file that is extracted is the user that is extracting it.
unzip offers a
-q (quiet) option that allows you to extract files without seeing the file listing.
unzip -q file.zip
-d (directory) option and supply the path to the directory you want the archive to be extracted into if you want the files to be extracted in a particular directory.
unzip -d ./development -q file.zip
We will then learn how to extract a file.
FILE EXPLORER into the taskbar search box, then choose it from the list of results.
To zip a file, right-click on it and choose
SEND TO > COMPRESSED (ZIPPED) FOLDER.
Use the right-click menu to choose
EXTRACT ALL, then follow the prompts to unzip the entire folder.
Alternatively, you can use the command ribbon to select
Double-clicking the compressed folder will open it and allow you to decompress a single file or folder. Next, move the item to a new location by dragging or copying it from the compressed folder.
Let’s look at how to unzip a file in a Unix system.
Often found on Unix systems,
unzip can list, test, or extract files from a ZIP archive.
When no options are selected, the default behavior extracts all of the files from the specified ZIP archive into the current directory and any subdirectories below it.
Assume we have three text files with names of
c.txt inside of a zip file called "jayesh_gfg.zip." We must extract the zip file to the current directory.
OUTPUT AND SYNTAX:
Here, we show every file that has been unzipped from the compressed file using the
[Extract a file]