cli-tarHow do I compress a single file using tar and gzip?
Compressing a single file using tar and gzip requires two steps:
- Create a tar file containing the file to be compressed:
tar -cf <file_name>.tar <file_to_compress>
This command will create a tar file named <file_name>.tar
containing the file <file_to_compress>
.
- Compress the tar file using gzip:
gzip <file_name>.tar
This command will compress the tar file, creating a file named <file_name>.tar.gz
.
The resulting <file_name>.tar.gz
file is the compressed version of the original file.
Code explanation
tar -cf <file_name>.tar <file_to_compress>
: creates a tar file containing the file to be compressedgzip <file_name>.tar
: compresses the tar file using gzip
Helpful links
More of Cli Tar
- How do I use the command line to tar and zip files?
- How do I convert a gzip file to a tar file?
- How can I use tar commands to zip a file?
- How do I use gzip, tar, and zip to compress 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 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 use the command line to tar and zip a file?
See more codes...