cli-tarHow do I compress a file using the Unix tar command?
The Unix tar command allows you to compress a file. The following example shows how to compress a file named file.txt
:
tar -czvf file.tar.gz file.txt
This command creates a compressed file named file.tar.gz
. The options used in this command are:
-c
: This option creates a new tar archive.-z
: This option compresses the tar archive with gzip.-v
: This option prints the progress of the compression to the terminal.-f
: This option tells tar to read or create the archive specified by the file name.
The output of the command should look like this:
file.txt
For more information about the tar command, please see the following links:
More of Cli Tar
- How do I use gzip, tar, and zip to compress files?
- How do I use the shell to tar and zip files?
- How do I use the Unix tar zip command?
- How do I use the command line to tar and distribute files?
- How do I create a tar.zip file in Unix?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and zip a file?
- How do I compress a file using gzip and tar.xz?
- How do I use the Unix tar xvf command to extract files?
- How do I use the command line to tar and zip files?
See more codes...